PDF export is slow or causes proxy timeout errors

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.

*Except Fisheye and Crucible

Problem

PDF exports take a long time to execute. The problem is noticed even on a blank page with no images or macros on it. If Confluence is behind a reverse proxy, we can see proxy timeout errors as well.

Analysis

Analysing tomcat logs catalina.out of Confluence shows long running threads like follows,

27-Jan-2021 14:14:26.952 WARNING [Catalina-utility-2] org.apache.catalina.valves.StuckThreadDetectionValve.notifyStuckThreadDetected Thread [http-nio-6734-exec-7] (id=[201]) has been active for [62,050] milliseconds (since [1/27/21 2:13 PM]) to serve the same request for [http://localhost:6734/c734/spaces/flyingpdf/pdfpageexport.action?pageId=3309571] and may be stuck (configured threshold for this StuckThreadDetectionValve is [60] seconds). There is/are [1] thread(s) in total that are monitored by this Valve and may be stuck.
	java.lang.Throwable
		at java.net.PlainSocketImpl.socketConnect(Native Method)
		at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
		at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
		at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
		at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
		at java.net.Socket.connect(Socket.java:589)
		at java.net.Socket.connect(Socket.java:538)
		at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
		at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
		at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
		at sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
		at sun.net.www.http.HttpClient.New(HttpClient.java:339)
		at sun.net.www.http.HttpClient.New(HttpClient.java:357)
		at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1220)
		at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
		at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
		at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:984)
		at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564)
		at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
		at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
		at org.xhtmlrenderer.swing.NaiveUserAgent.onHttpConnection(NaiveUserAgent.java:174)
		at org.xhtmlrenderer.swing.NaiveUserAgent.openConnection(NaiveUserAgent.java:157)
		at org.xhtmlrenderer.swing.NaiveUserAgent.openStream(NaiveUserAgent.java:142)
		at org.xhtmlrenderer.swing.NaiveUserAgent.resolveAndOpenStream(NaiveUserAgent.java:129)
		at com.atlassian.confluence.extra.flyingpdf.impl.AbstractExportUserAgent.resolveAndOpenStream(AbstractExportUserAgent.java:92)
		at org.xhtmlrenderer.swing.NaiveUserAgent.getCSSResource(NaiveUserAgent.java:218)
		at org.xhtmlrenderer.context.StylesheetFactoryImpl.parse(StylesheetFactoryImpl.java:91)
		at org.xhtmlrenderer.context.StylesheetFactoryImpl.getStylesheet(StylesheetFactoryImpl.java:179)
		at org.xhtmlrenderer.context.StyleReference.readAndParseAll(StyleReference.java:124)
		at org.xhtmlrenderer.context.StyleReference.setDocumentContext(StyleReference.java:112)
		at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:189)
		at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:156)
		at com.atlassian.confluence.extra.flyingpdf.impl.FlyingSaucerXmlToPdfConverter.convertXhtmlToPdf(FlyingSaucerXmlToPdfConverter.java:107)
		at com.atlassian.confluence.extra.flyingpdf.impl.FlyingSaucerXmlToPdfConverter.convertXhtmlToPdf(FlyingSaucerXmlToPdfConverter.java:75)


If threads dumps are taken, we also see the same stack trace.

"http-nio-6734-exec-7" #201 daemon prio=5 os_prio=31 tid=0x00007f9583fd8800 nid=0x18d03 runnable [0x000070001c19f000]
   java.lang.Thread.State: RUNNABLE
	at java.net.PlainSocketImpl.socketConnect(Native Method)
	at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:350)
	- locked <0x00000007a866da80> (a java.net.SocksSocketImpl)
	at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:206)
	at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:188)
	at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:392)
	at java.net.Socket.connect(Socket.java:589)
	at java.net.Socket.connect(Socket.java:538)
	at sun.net.NetworkClient.doConnect(NetworkClient.java:180)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:463)
	at sun.net.www.http.HttpClient.openServer(HttpClient.java:558)
	- locked <0x00000007a866d9f8> (a sun.net.www.http.HttpClient)
	at sun.net.www.http.HttpClient.<init>(HttpClient.java:242)
	at sun.net.www.http.HttpClient.New(HttpClient.java:339)
	at sun.net.www.http.HttpClient.New(HttpClient.java:357)
	at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:1220)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect0(HttpURLConnection.java:1156)
	at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:1050)
	at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:984)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream0(HttpURLConnection.java:1564)
	- locked <0x00000007a866c738> (a sun.net.www.protocol.http.HttpURLConnection)
	at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1492)
	- locked <0x00000007a866c738> (a sun.net.www.protocol.http.HttpURLConnection)
	at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:480)
	at org.xhtmlrenderer.swing.NaiveUserAgent.onHttpConnection(NaiveUserAgent.java:174)
	at org.xhtmlrenderer.swing.NaiveUserAgent.openConnection(NaiveUserAgent.java:157)
	at org.xhtmlrenderer.swing.NaiveUserAgent.openStream(NaiveUserAgent.java:142)
	at org.xhtmlrenderer.swing.NaiveUserAgent.resolveAndOpenStream(NaiveUserAgent.java:129)
	at com.atlassian.confluence.extra.flyingpdf.impl.AbstractExportUserAgent.resolveAndOpenStream(AbstractExportUserAgent.java:92)
	at org.xhtmlrenderer.swing.NaiveUserAgent.getCSSResource(NaiveUserAgent.java:218)
	at org.xhtmlrenderer.context.StylesheetFactoryImpl.parse(StylesheetFactoryImpl.java:91)
	at org.xhtmlrenderer.context.StylesheetFactoryImpl.getStylesheet(StylesheetFactoryImpl.java:179)
	at org.xhtmlrenderer.context.StyleReference.readAndParseAll(StyleReference.java:124)
	at org.xhtmlrenderer.context.StyleReference.setDocumentContext(StyleReference.java:112)
	at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:189)
	at org.xhtmlrenderer.pdf.ITextRenderer.setDocument(ITextRenderer.java:156)
	at com.atlassian.confluence.extra.flyingpdf.impl.FlyingSaucerXmlToPdfConverter.convertXhtmlToPdf(FlyingSaucerXmlToPdfConverter.java:107)
	at com.atlassian.confluence.extra.flyingpdf.impl.FlyingSaucerXmlToPdfConverter.convertXhtmlToPdf(FlyingSaucerXmlToPdfConverter.java:75)

Diagnosis

Verify that Confluence can connect to it's Base URL. This can be recognised as errors in logs or by using httpclienttest for a more concrete test.

Run this from Confluence Server
java -jar httpclienttest-1.0.2.jar <Confluence Base URL>

In case there are any issues with the above command, we can be certain that PDF exports are being stalled due to lack of connection to the BaseURL.

Resolution

PDF export requires connectivity of Confluence with it's Base URL. Ensure that any network components like firewalls or proxy servers are not blocking this connection.



DescriptionPDF export is slow due to network issues with Base URL
ProductConfluence
Last modified on Jan 27, 2021

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.