andunslg
andunslg

Reputation: 791

Reconnecting the Connection on Disconnect Event due to Network Failure - Socket.io

I am using socket.io to implement a real-time application. The client(Mobile phone web pages) connection get disconnects some time due to heartbeat test failure. That happened due to network issues. Is there a way to reconnect the connection on disconnect event from client side?

Upvotes: 0

Views: 345

Answers (1)

dizballanze
dizballanze

Reputation: 1267

You can tune socket.io options to enable reconnection.

  • reconnection - should be true
  • reconnectionDelay (ms) - how long to wait before attempting a new reconnection
  • reconnectionDelayMax (ms) - maximum amount of time to wait between reconnections. Each attempt increases the reconnection by the amount specified by reconnectionDelay.

Upvotes: 1

Related Questions