wkhtmltopdf hangs went trying to convert certain urls-Collection of common programming errors
I’m running into an issue when converting user-provided urls into PDFs of the given page. I’m using PDFKit to do so with the following code:
kit = PDFKit.new(url)
pdf = kit.to_file("/tmp/#{SecureRandom.hex}.pdf")
This works for most urls, but occasionally hangs for up to an hour. The urls that cause it to hang seem to do so repeatedly. I’ve tried removing PDFKit from the equation and calling wkhtmltopdf directly, like this:
path = "/tmp/#{SecureRandom.hex}.pdf"
`wkhtmltopdf --page-size Letter --margin-top 0.75in --margin-right 0.75in --margin-bottom 0.75in --margin-left 0.75in --encoding UTF-8 --ignore-load-errors #{url} #{path}`
pdf = File.open(path)
This still hangs, with the following output:
Loading pages (1/5)
No bp log location saved, using default.==============> ] 89%
objc[91413]: Class MacCocoaSocketServerHelper is implemented in both /Library/Internet Plug-Ins/googletalkbrowserplugin.plugin/Contents/MacOS/googletalkbrowserplugin and /Library/Internet Plug-Ins/o1dbrowserplugin.plugin/Contents/MacOS/o1dbrowserplugin. One of the two will be used. Which one is undefined.
No bp log location saved, using default.
QSslSocket::connectToHostEncrypted() called when already connecting/connected
Warning: SSL error ignored
An example of a URL that causes this is http://www.indiandefencereview.com/news/optimal-employment-of-sophisticated-equipment-needs-high-quality-manpower/.
I have seen some complaints of wkhtmltopdf not handling SSL properly, but it looked like the suggestions were to make sure that openssl is installed (it is).
Would really appreciate any help or ideas.
Originally posted 2013-11-26 18:03:51.