Laravel 5.5 - Laravel-Snappy PDF 生成 -> 由于未知网络错误导致的运行时异常

Laravel 5.5 - Laravel-Snappy PDF Generation -> RuntimeException due to UnknownNetworkError

我正在使用 5.5 的框架,最近下载了 wkhtmltopdf-amd64 包的 0.12.5 (dev-master) 来尝试解决这个错误。

我知道这通常是由于 html 中的 SSL (https) url 造成的,但是我已经得到了我正在尝试打印的文件,它在我的生产环境中确实有效。

我更改了测试环境中的新代码(已修改为使用 font awesome 5),以便它仅使用 v4。据我所知,文件中的链接(其中 1 个有效,1 个无效)是相同的。

我的测试文件 html 中是否还有其他问题会导致此处显示的错误:

(1/1) RuntimeException
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
[========> ] 14%
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_library_init
Warning: Failed to load https://mcentric-test.herokuapp.com/css/jumbotron.css (ignore)
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_library_init
QSslSocket: cannot call unresolved function SSLv23_client_method
QSslSocket: cannot call unresolved function SSL_library_init
Warning: Failed to load https://mcentric-test.herokuapp.com/images/mCentric_logo.png (ignore)
Warning: Failed to load https://mcentric-test.herokuapp.com/images/meeting.jpg (ignore)
Warning: Failed to load https://mcentric-test.herokuapp.com/images/outlook.jpg (ignore)
Warning: Failed to load https://mcentric-test.herokuapp.com/images/google.jpg (ignore)
Warning: Failed to load https://mcentric-test.herokuapp.com/images/yahoo.jpg (ignore)
Warning: Failed to load https://mcentric-test.herokuapp.com/images/ical.jpg (ignore)
Warning: Failed to load https://mcentric-test.herokuapp.com/images/mCentric_logo_blue.png (ignore)
[============================================================] 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: /app/vendor/bin/wkhtmltopdf-amd64 --lowquality --load-error-handling 'ignore' '/tmp/knp_snappy5bd9df39f00ca0.32809410.html' '/tmp/knp_snappy5bd9df39f02363.36498894.pdf'.

in AbstractGenerator.php line 378

html produced from test server

html produced on production server (that does NOT error out) 重申一下,需要 6 个 https 链接进行格式化的外观确实使用 0.12.4 二进制文件成功创建了 PDF。

并且 0.12.4 和 0.12.5 二进制文件(在测试环境中尝试时)都无法创建 PDF 并导致上面的错误文本。

我发布这个答案是为了让某人免于以后不断审查这个问题的痛苦。

测试和生产环境是 heroku 托管环境。

wkhtmltopdf-amd64 二进制文件在 cedar-14 堆栈(生产)上运行良好。

测试环境的堆栈已升级,这似乎是它停止工作的原因。

https://github.com/barryvdh/laravel-snappy/issues/217#issuecomment-464012852

https://github.com/barryvdh/laravel-snappy/issues/217#issuecomment-680619400

低版本不支持HTTPS 升级到任何最新版本。