Question

I'm running this script under nginx+apache. It sends large data packages (split into portions) to a remote server, calling cURL execution in cycle. Strange thing to me is, that after timeout I receive 504 error into browser (captain), but script continues to run anyway!

I've tested it - and script is sending all the data I require it to send, so technically, it's not a problem. But I think that any unusual stuff like this might have it's consequences in future.

I would appreciate any knowledge that more experienced developers might share on this issue.

Was it helpful?

Solution

The 504 is sent by the server if you reach the max execution time (in Apache it defaults to 30 seconds). However the script still runs in the background -- it just stops sending data to the client. If you anticipate your script running for more than the max execution time and want to see the data it returns, you should consider either upping the max execution time setting on your server or running the script elsewhere and reporting back to the browser via a socket connection or interval polling.

On another note, why are you using nginx AND apache? Or do you mean that it does the same thing on both?

OTHER TIPS

I'm getting the same issue as this. I'd like to say a few things here.

504 error is sent from the nginx server. You can prevent this error by increasing timeout settings in nginx server (/etc/nginx/proxy.inc). Here are configures on my server

proxy_send_timeout 600; // 10 minutes proxy_read_timeout 600; // 10 minutes

So if your script take more than 10 minutes, then you will see the 504 error appears.

Max execute time is 30 seconds as default. I believe you have increased it so that the script can continue to execute after 504 error. How about if you set max execute time to one value that be equal to nginx's timeout value (10 minutes as above)?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top