I am getting 504 timeouts message from nginx when my PHP script is running longer than usual. set_time_limit(0) does not seem to prevent that! Does it not work
There are three kinds of timeouts which can occur in such a case. It can be seen that each answer is focused on only one aspect of these possibilities. So, I thought to write it down so someone visiting here in future does not need to randomly check each answer and get success without knowing which worked.
So the fixes for each issue are as follows.
$.ajax({
url: "test.html",
error: function(){
// will fire when timeout is reached
},
success: function(){
//do something
},
timeout: 3000 // sets timeout to 3 seconds
});
nginx Client timeout
http{
#in seconds
fastcgi_read_timeout 600;
client_header_timeout 600;
client_body_timeout 600;
}
nginx proxied server timeout
http{
#Time to wait for the replying server
proxy_read_timeout 600s;
}
So use the one that you need. Maybe in some cases, you need all these configurations. I needed.