Laravel-snappy 在服务器执行的时候报如下错误,本地正常,求解?

RuntimeException in AbstractGenerator.php line 378:
The exit status code '1' says something went wrong:
stderr: "Loading pages (1/6)
[> ] 0%
[======> ] 10%
QSslSocket: cannot resolve CRYPTO_num_locks
QSslSocket: cannot resolve CRYPTO_set_id_callback
QSslSocket: cannot resolve CRYPTO_set_locking_callback
QSslSocket: cannot resolve sk_free
QSslSocket: cannot resolve sk_num
QSslSocket: cannot resolve sk_pop_free
QSslSocket: cannot resolve sk_value
QSslSocket: cannot resolve SSL_library_init
QSslSocket: cannot resolve SSL_load_error_strings
QSslSocket: cannot resolve SSLv3_client_method
QSslSocket: cannot resolve SSLv23_client_method
QSslSocket: cannot resolve SSLv3_server_method
QSslSocket: cannot resolve SSLv23_server_method
QSslSocket: cannot resolve X509_STORE_CTX_get_chain
QSslSocket: cannot resolve OPENSSL_add_all_algorithms_noconf
QSslSocket: cannot resolve OPENSSL_add_all_algorithms_conf
QSslSocket: cannot resolve SSLeay
QSslSocket: cannot call unresolved function CRYPTO_num_locks
QSslSocket: cannot call unresolved function CRYPTO_set_id_callback
QSslSocket: cannot call unresolved function CRYPTO_set_locking_callback
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function sk_num
[ =========> ] 16%
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_library_init
HeleeXiao
《L04 微信小程序从零到发布》
从小程序个人账户申请开始,带你一步步进行开发一个微信小程序,直到提交微信控制台上线发布。
《L02 从零构建论坛系统》
以构建论坛项目 LaraBBS 为线索,展开对 Laravel 框架的全面学习。应用程序架构思路贴近 Laravel 框架的设计哲学。
讨论数量: 8
HeleeXiao

以及如下半段
[============================================================] 100%
Counting pages (2/6)
[============================================================] Object 1 of 1
Resolving links (4/6)
[============================================================] Object 1 of 1
Loading headers and footers (5/6)
Printing pages (6/6)
[> ] Preparing
[============================================================] Page 1 of 1
Done
Exit with code 1 due to network error: UnknownNetworkError
QSslSocket: cannot call unresolved function CRYPTO_num_locks
QSslSocket: cannot call unresolved function CRYPTO_set_id_callback
QSslSocket: cannot call unresolved function CRYPTO_set_locking_callback
"
stdout: ""
command: /home/services/qtin-end-cms-x/vendor/h4cc/wkhtmltopdf-amd64/bin/wkhtmltopdf-amd64 --lowquality --
page-size 'a4' '/tmp/knp_snappy5a29036e53ac81.28775171.html' '/tmp/knp_snappy5a2906.pdf'.

7年前 评论
xuding

遇到过类似问题。
wkhtmltopdf和OS的兼容性。
解决方法根据你的系统而不同,可以看这个https://github.com/wkhtmltopdf/wkhtmltopdf/issues/3001。

我的情况靠更新wkhtmltopdf解决的。

希望有所帮助。

7年前 评论
HeleeXiao

@XuDing 谢谢 已从您推荐的地方找到解决办法。

7年前 评论
zhaoguangshuai 5年前
king-wang 4年前
inkelune 3年前
the_big_feng_feng

查看是否引用了字体,注释掉引用的字体试一下

4年前 评论

我是通过以下两步解决这个问题的。希望有帮助

网上有说是要降低ssl版本,我这里没有尝试这种方式,有两个原因:

1、我发现我的版本并不高

[root@centos bin]# openssl version
OpenSSL 1.0.2k-fips  26 Jan 2017

2、其次就是我导出的时候也没有强制要求https

第一步:尝试了在文件这里 vendor\knplabs\knp-snappy\src\Knp\Snappy\AbstractGenerator.php 修改了下

I also get this issue in windows 10.
then I found this QA
and fixed it by changing in executeCommand function
vendor\knplabs\knp-snappy\src\Knp\Snappy\AbstractGenerator.php
$process->getExitCode()!=1?:0,
return [
            $process->getExitCode,
            $process->getOutput(),
            $process->getErrorOutput(),
        ];

to
return [
            $process->getExitCode()!=1?:0,
            $process->getOutput(),
            $process->getErrorOutput(),
        ];

结果,没多久,又报错了这个错误了。mmmmm

第二步: vendor\knplabs\knp-snappy\src\Knp\Snappy\AbstractGenerator.php 注释掉两行,
并加上 exec($command);

exec($command);
// list($status, $stdout, $stderr) = $this->executeCommand($command);
// $this->checkProcessStatus($status, $stdout, $stderr, $command);

如下图:

I narrowed it down to being a problem with the Symfonys Process Class, used in the executeCommand method of the AbstractGenerator class.
$process = new \Symfony\Component\Process\Process($command, NULL, $this->env);

I solved the problem with a hack, replacing the executeCommand method in generate with directly executing the command:
public function generate($input, $output, array $options = array(), $overwrite = false)
    {
        if (null === $this->binary) {
            throw new \LogicException(
                'You must define a binary prior to conversion.'
            );
        }

        $this->prepareOutput($output, $overwrite);

        $command = $this->getCommand($input, $output, $options);

        /** Workaround for Windows Server 2008 + IIS7 */
        exec($command);
//         list($status, $stdout, $stderr) = $this->executeCommand($command);
//         $this->checkProcessStatus($status, $stdout, $stderr, $command);
        /** Workaround End */

        $this->checkOutput($output, $command);
    }

I wasn't really satisfied with that solution, but it worked the last two months without any problems.

参考:github.com/barryvdh/laravel-snappy...

3年前 评论

讨论应以学习和精进为目的。请勿发布不友善或者负能量的内容,与人为善,比聪明更重要!