Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Reconnecting in Socket.io and maintaining client id?

Is this possible? I can't find any documentation on the subject but from the tests I've done so far, a new client id is assigned every time a client reconnects. If its not possible what would be the best workaround? Thanks!

like image 538
uguMark Avatar asked Jan 23 '12 15:01

uguMark


People also ask

Does Socket.IO reconnect automatically?

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

How do you check if socket IO client is connected or not?

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

What is the difference between Socket.IO and socket IO client?

socket-io. client is the code for the client-side implementation of socket.io. That code may be used either by a browser client or by a server process that is initiating a socket.io connection to some other server (thus playing the client-side role in a socket.io connection).


1 Answers

At the moment I don't think it's possible (I've asked the same question myself to `3rd-Eden, Socket.IO core dev).

However you can setup some unique key yourself on the client's session, that's the best workaround at the moment and usually people find this ok (for example put the username on the session or another unique id).

like image 108
alessioalex Avatar answered Sep 21 '22 00:09

alessioalex