HTTP 504 timeout after exactly 120 seconds

I have a server application that runs in the Amazon EC2 cloud. From my client (browser), I make an HTTP request that uploads the file to the server, which then processes the file. If there is a lot of processing (large file), the server always shuts down with the error of continuing the 504 backup, always after exactly 120 seconds. Although I get this error, the server continues to process the request and completes it (checked by checking the database), but I do not see the final result on my client due to the timeout.

I do not know why this is happening. Has anyone encountered a similar 504 timeout? Is there an intermediate proxy server not in my control that is disabled?

+6
amazon-s3 amazon-ec2 timeout
source share
3 answers

I have a similar problem, and in my case, I believe this is due to the connection between the Elastic Load Balancer (ELB) and the EC2 instance.

For a long-term solution, I will go over with processing the answer "Status" + "back-end" 303 proposed by james.garriss above.

For a short-term solution, it may be possible for Amazon support to increase the ELB timeout (see their answer at https://forums.aws.amazon.com/thread.jspa?messageID=491594񸁊 ). Unfortunately, there seems to be no way to change the timeout yourself through the API or the console.

[ Update ] AWS now allows you to update the idle timeout either through console configuration, CLI, or .ebextensions. See http://docs.aws.amazon.com/ElasticLoadBalancing/latest/DeveloperGuide/config-idle-timeout.html (thanks @Daniel Patz for the update)

+5
source

Assuming that the correct status code is returned, the problem is that the intermediate proxy is shutting down. "The server, acting as a gateway or proxy, did not receive a timely response from the upstream server specified in the URI." (http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html#sec10.5.5) Most likely, this indicates that the source server has some kind of problem (i.e. it takes a long time to processing your request), so it does not respond quickly.

Perhaps the best solution is to re-create your server application so that it responds with the status code "303 See Other"; then your client can receive the data at a later data point as soon as the server completes the processing and creates the final result.

Edit: Another idea is to re-create the server application so that it responds with a 413 Request Entity Too Large status code when the size of the request entity is too large. This will save you from the error, although it may make your application less useful if it can only process "small" files. "

Other possible solutions:

  • Increase the timeout for the proxy (if it is under your control)
  • Make your request on another server (if there is another, faster server with the same application)
  • Make your request different (if possible) so that you send less data at a time
+1
source

it is possible that the browser timeouts during the execution of the script.

0
source

All Articles