socket.io client reconnect timeout

Viewed 21517

I'm using socket.io with node.js and I like the solution. The only issue I notice is around a disconnection and reconnection.

These are my current settings:

  'connect timeout': 1000,
  'reconnect': true,
  'reconnection delay': 300,
  'max reconnection attempts': 10000,
  'force new connection':true

I notice if I stop and start the node.js process the client connects back fine and quickly, however if the server is offline for a couple of minutes the client either never reconnects or takes a very long (non-user friendly) amount of time to.

I wanted to ask if there is anything I've missed or could add to the socket.io configuration to keep the client polling for a reconnection.

I know 'reconnection delay':

reconnection delay defaults to 500 ms

The initial timeout to start a reconnect, this is increased using an exponential back off algorithm each time a new reconnection attempt has been made.

But the exponential effect its not very user friendly. Is there a way to keep checking for a connection every X period of time - eg: 5 seconds.

If not I guess I can write some client side JS to check the connect and attempt reconnections if needed but it would be nice if the socket.io client offered this.

thx

3 Answers
Related