Reputation: 568
I have a node.js application with socket.io running on an nginx server. The problem is the websocket connection gets timeouted by the nginx, 30 seconds after the connection, even though the connection doesn't remain idle for the whole time. This is my nginx.conf file;
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log;
pid /run/nginx.pid;
include /usr/share/nginx/modules/*.conf;
events {
worker_connections 1024;
}
stream {
upstream cluster {
least_conn;
server xx.xxx.xxx.xx:2157;
}
server {
listen 7000;
preread_timeout 86400s;
proxy_timeout 86400s;
proxy_pass cluster;
}
}
The nginx version is: 1.12.2
Upvotes: 1
Views: 3020
Reputation: 568
PS: It was actually the node.js app itself that closes the connection of the client.
I've added this line of code io.set('heartbeat timeout', 24*60*60);
to my node.js application and the timeout wasn't an issue anymore.
Upvotes: 1