var socket = io(); reconnect 1

var socket = io(); reconnect

var socket = io({
  'reconnection': true,
  'reconnectionDelay': 1000,
  'reconnectionDelayMax' : 5000,
  'reconnectionAttempts': 5
});

Here is what the above code is Doing:
1. We’re creating a new socket.io client and assigning it to a variable called socket.
2. We’re passing in an object with some options to the socket.io client.
3. We’re telling the socket.io client to try to reconnect if the connection is lost.
4. We’re telling the socket.io client to wait 1 second before trying to reconnect.
5. We’re telling the socket.io client to wait a maximum of 5 seconds before trying to reconnect.
6. We’re telling the socket.io client to try to reconnect 5 times before giving up.

Similar Posts