504 Gateway Time-out on PDF export
Asked by Pini Shvartsman:

I'm getting a 504 Gateway Time-out when I try to export to PDF.

this is the stack trace:

08-Nov-2020 15:40:07.040 WARNING \[Catalina-utility-2\] org.apache.catalina.valves.StuckThreadDetectionValve.notifyStuckThreadDetected Thread \[http-nio-8090-exec-6\] (id=\[182\]) has been active for \[64,184\] milliseconds (since \[11/8/20 3:39 PM\]) to serve the same request for \[[\*\*\*\*/spaces/flyingpdf/pdfpageexport.action?pageId=327726](https://****/spaces/flyingpdf/pdfpageexport.action?pageId=327726)\] 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.base@11.0.7/java.net.PlainSocketImpl.socketConnect(Native Method)  
at java.base@11.0.7/java.net.AbstractPlainSocketImpl.doConnect(Unknown Source)  
at java.base@11.0.7/java.net.AbstractPlainSocketImpl.connectToAddress(Unknown Source)  
at java.base@11.0.7/java.net.AbstractPlainSocketImpl.connect(Unknown Source)  
at java.base@11.0.7/java.net.SocksSocketImpl.connect(Unknown Source)


Answers:
author: Daniel Ebers
body: Hi Pini,

this leads to the assumption that the export is too big to execute in a timely manner leading to a timeout. Probably (while not sure) this is related to a memory shortage but it needs further inspection.

Does this happen recently "at once" or did you upgrade Confluence before?  
Could you please share some basic specs about your instance (number of spaces/pages/users + amount of memory assigned to the JVM would be helpful)?.

Please also review the following article if it matches:  
<https://confluence.atlassian.com/confkb/confluence-times-out-when-trying-to-export-a-page-to-pdf-990551836.html>

In case you could provide more details a Confluence-versed user here on Community might be able to advise with more details.

Cheers,  
Daniel

comments: author: Pini Shvartsman
body: Thank you for the response.

I looked over this article and there is no problem with the server memory.

I also changed the configurations for the timeout in Nginx on the server and it still fails (after long minutes)  

The current Confluence setup is on a new server but the old setup was running on a similar server but I didn't have those issues with the export.


author: Daniel Ebers
body: Is it in your case also given that the PDF is correctly stored in temp folder (despite the UI is showing an error) as documented in this bug?  
<https://jira.atlassian.com/browse/CONFSERVER-36883>

Are there error messages in logs that correspond to the information put in the bug report?

A more general question: which version of Confluence is it exactly you are running?


author: Pini Shvartsman
body: The temp folder does not contain the PDF:

![Untitled.png](https://community.atlassian.com/t5/image/serverpage/image-id/117827i2E54DF863A08B705/image-size/large?v=v2&px=999 "Untitled.png")as for the logs, this is the only log I can see:  

```
11-Nov-2020 12:37:19.288 WARNING [Catalina-utility-2] org.apache.catalina.valves.StuckThreadDetectionValve.notifyStuckThreadDetected Thread [http-nio-8090-exec-2] (id=[179]) has been active for [66,948] milliseconds (since [11/11/20 12:36 PM]) to serve the same request for [https://URL/spaces/flyingpdf/pdfpageexport.action?pageId=2850818] 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.
```


author: Daniel Ebers
body: Could you please confirm on the version of Confluence that you are running?


author: Pini Shvartsman
body: Powered by Atlassian Confluence 7.8.3


Tags: confluence-server

server