{"id":1525,"date":"2022-08-30T15:17:15","date_gmt":"2022-08-30T15:17:15","guid":{"rendered":"https:\/\/unknownerror.org\/index.php\/2013\/11\/26\/wkhtmltopdf-hangs-went-trying-to-convert-certain-urls-collection-of-common-programming-errors\/"},"modified":"2022-08-30T15:17:15","modified_gmt":"2022-08-30T15:17:15","slug":"wkhtmltopdf-hangs-went-trying-to-convert-certain-urls-collection-of-common-programming-errors","status":"publish","type":"post","link":"https:\/\/unknownerror.org\/index.php\/2022\/08\/30\/wkhtmltopdf-hangs-went-trying-to-convert-certain-urls-collection-of-common-programming-errors\/","title":{"rendered":"wkhtmltopdf hangs went trying to convert certain urls-Collection of common programming errors"},"content":{"rendered":"<p>I&#8217;m running into an issue when converting user-provided urls into PDFs of the given page. I&#8217;m using PDFKit to do so with the following code:<\/p>\n<pre><code>kit = PDFKit.new(url)\npdf = kit.to_file(\"\/tmp\/#{SecureRandom.hex}.pdf\")\n<\/code><\/pre>\n<p>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&#8217;ve tried removing PDFKit from the equation and calling wkhtmltopdf directly, like this:<\/p>\n<pre><code>path = \"\/tmp\/#{SecureRandom.hex}.pdf\"\n`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}`\npdf = File.open(path)\n<\/code><\/pre>\n<p>This still hangs, with the following output:<\/p>\n<pre><code>Loading pages (1\/5)\n\nNo bp log location saved, using default.==============&gt;      ] 89%\n\nobjc[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.\n\nNo bp log location saved, using default.\n\nQSslSocket::connectToHostEncrypted() called when already connecting\/connected\n\nWarning: SSL error ignored\n<\/code><\/pre>\n<p>An example of a URL that causes this is http:\/\/www.indiandefencereview.com\/news\/optimal-employment-of-sophisticated-equipment-needs-high-quality-manpower\/.<\/p>\n<p>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).<\/p>\n<p>Would really appreciate any help or ideas.<\/p>\n<p id=\"rop\"><small>Originally posted 2013-11-26 18:03:51. <\/small><\/p>","protected":false},"excerpt":{"rendered":"<p>I&#8217;m running into an issue when converting user-provided urls into PDFs of the given page. I&#8217;m using PDFKit to do so with the following code: kit = PDFKit.new(url) pdf = kit.to_file(&#8220;\/tmp\/#{SecureRandom.hex}.pdf&#8221;) This works for most urls, but occasionally hangs for up to an hour. The urls that cause it to hang seem to do so [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[],"class_list":["post-1525","post","type-post","status-publish","format-standard","hentry","category-uncategorized"],"_links":{"self":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1525","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/comments?post=1525"}],"version-history":[{"count":0,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/posts\/1525\/revisions"}],"wp:attachment":[{"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/media?parent=1525"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/categories?post=1525"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/unknownerror.org\/index.php\/wp-json\/wp\/v2\/tags?post=1525"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}