How to reconnect to socket io once disconnect
has been called?
Here\'s the code
function initSocket(__bool){
if(
This is an old question, but I was struggling with this recently and stumbled here. Most recent versions of socket.io (>2.0) doesn't have the socket.socket
property anymore as pointed out here.
I am using socket.io-client 2.2.0
and I was facing a situation where the socket seems to be connected (property socket.connected = true
) but it wasn't communicating with the server.
So, to fix that, my solution was call socket.close()
and socket.open
. These commands force a disconnection and a new connection.