Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

socket.io reconnect example

the socket.io docs says we should implement our own reconnect?

Does anyone have an example of a simple reconnect scheme?

The idea is that if the user reconnects within 20 seconds he should be given the same socket.io sessionid.

like image 984
Harry Avatar asked Jun 03 '11 19:06

Harry


People also ask

Does Socket.IO auto reconnect?

In the first case, the Socket will automatically try to reconnect, after a given delay.

Does Socket.IO reconnect after disconnect?

Socket disconnects automatically, reconnects, and disconnects again and form a loop. #918.

How can I tell if Socket.IO is connected?

You can check the socket. connected property: var socket = io. connect(); console.


1 Answers

socket.io has reconnect support now, using the options reconnect and reconnectionDelay so you can let that handle everything for you if you need.

like image 71
pthurlow Avatar answered Oct 10 '22 02:10

pthurlow