Skip to content

Client disconnects and reconnects to websocket persistently

I am connected via 1.3.4 (via websockets) to the NodeJS server and client 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.

  1. How can I debug this issue?

  2. How can I see who is guilty – server or client?

  3. How does understands that it is time to disconnect? Could not understand this from their code.

Edit. config:

io = require('')(server, { 
      log: false
    , "close timeout": 60
    , "heartbeat timeout": 60
    , "heartbeat interval": 20



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. sends heartbeats every 25 seconds, so make sure you set those timeouts to something greater than 25s.