Http request timeout at 2 minutes in NGINX 502 bad gateway in Node app Http request timeout at 2 minutes in NGINX 502 bad gateway in Node app angularjs angularjs

Http request timeout at 2 minutes in NGINX 502 bad gateway in Node app


I just came across this today, and probably found an answer - there is 120 s hard coded timeout in node's http module. I had to set socket timeout in given request handler like this:

yourHandler(req, res) {  req.socket.setTimeout(3600e3); // 1 hour  // ... do the real work  res.json(...);}

You can also set this limit to 0 to disable this timeout.

https://nodejs.org/api/net.html#net_socket_settimeout_timeout_callback

originally found the answer here: https://forum.nginx.org/read.php?2,214230,214239#msg-214239