socket.io: socket reconnect in version 1.0

196 views Asked by At

I'm trying to migrate from Socket.IO 0.9 to 1.2.1, and I'm having some difficulty with socket reconnection. In 0.9, I could do something like socket.socket.reconnect();, but unfortunately, socket.socket doesn't exist and socket.io.reconnect doesn't seem to reconnect my socket. However, socket.connect() seems to reconnect using my original connect settings, but this doesn't seem right... why can't I use reconnect? I've looked at this thread, but forceNew didn't seem to help. Just for completion's sake, my connect code looks like this:

var socket = io.connect('/myNamespace', {forceNew: true, path: '/path/to/socket.io'});
2

There are 2 answers

0
incutonez On BEST ANSWER

I ended up using socket.connect()... if anyone has a solution with .reconnect(), I'm all ears.

0
philippe ilharreguy On

A possible workaround to this issue is to execute:

 socket.io.skipReconnect = false;
 socket.io.reconnect();