I am connected via Socket.io 1.3.4 (via websockets) to the NodeJS server and client socket.io fires up “disconnect” event 5-30 seconds.
Every “disconnect”->”reconnecting”->”reconnect” iteration takes approx. 2 seconds. I am connected via cable to pretty stable network. Server is hosted on AWS.
Sometimes I have bad Wi-Fi connection, but no “disconnect” event fire up at all.
How can I debug this issue?
How can I see who is guilty – server or client?
How does socket.io understands that it is time to disconnect? Could not understand this from their code.
Edit. Socket.io config:
io = require('socket.io')(server, { log: false , "close timeout": 60 , "heartbeat timeout": 60 , "heartbeat interval": 20 })
Advertisement
Answer
I had a similar issue with nginx running in front of node, and it was because proxy_read_timeout
and proxy_send_timeout
were set too low. Socket.io sends heartbeats every 25 seconds, so make sure you set those timeouts to something greater than 25s.