My server is node.js and I use nginx as a reverse proxy.
Now I have to do a time-consuming https request, but I always get the 504 Gateway Time-out error. and nginx/error.log says:
"upstream timed out"
So I change nginx conf to:
proxy_read_timeout 600;
proxy_connect_timeout 600;
client_max_body_size 32M;
client_body_buffer_size 512k;
proxy_send_timeout 600;
proxy_buffers 32 4k;
This time there will be no 504 error, but it turn to be 502 error, and nginx/error says:
"upstream prematurely closed connection"
And I find the error will just appear after I start the request for 120s.
My request process will sure take more than 120s, because it will do a time-consuming mysql query.
So I do not know how to get rid of the 502 error.
From what you describe, you problem is on the server now. You need to set the timeout both on nginx and t he web server. By default, node has a default timeout of 2 minutes.
Look at the server.setTimeout option: http://nodejs.org/api/http.html#http_server_settimeout_msecs_callback
Hope this helps.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With