socket.io icon indicating copy to clipboard operation
socket.io copied to clipboard

reconnect fails after net::ERR_INTERNET_DISCONNECTED

Open Remo opened this issue 11 years ago • 5 comments

I've been testing this with http://chat.socket.io/ using the latest chrome version. When my connect is lost for a while and then comes backup socket.io fails to reconnect. I get an ERR_INTERNET_DISCONNECTED which seems to stop everything.

Any ideas on how to get reconnect working reliably?

image

Remo avatar Jul 29 '15 16:07 Remo

Try adding a reconnection action fired on disconnect event. Probably in a loop till connection is established. On 29 Jul 2015 22:29, "Remo Laubacher" [email protected] wrote:

I've been testing this with http://chat.socket.io/ using the latest chrome version. When my connect is lost for a while and then comes backup socket.io fails to reconnect. I get an ERR_INTERNET_DISCONNECTED which seems to stop everything.

Any ideas on how to get reconnect working reliably?

[image: image] https://cloud.githubusercontent.com/assets/129864/8964071/c50ceba2-3623-11e5-812c-f579a49b19d4.png

— Reply to this email directly or view it on GitHub https://github.com/socketio/socket.io/issues/2189.

maxzeroedge avatar Jul 29 '15 17:07 maxzeroedge

thanks @maxzeroedge will try to add this http://stackoverflow.com/a/4433929 and report back

Remo avatar Jul 29 '15 17:07 Remo

unfortunately I get another error on my local computer, here's the debug log with polling. websocket didn't work because socket.io with websockets doesn't work with android 4.1. I've added a reconnect mechanism, but it's again just stuck after a while being offline.

image

Any ideas? And best practices to get a stable websocket connection with reconnect and everything?

Remo avatar Jul 30 '15 05:07 Remo

it's incredibly stupid, but so far this works quite well:

function checkConnection() {
    if (!socket.connected) {
        // try to connect again
        socket.connect();

        // seems like we have to join our room after reconnecting!
        socket.emit('join', {'room': roomName});
    }
}

setInterval(checkConnection, 1000);

Remo avatar Jul 30 '15 06:07 Remo

it's super hard to re-produce, but I think there are still some cases where socket.io gets stuck in limbo. I can't give you any better feedback, going to close this. If anyone can/wants to give more some hints about how to track down this issue, let me know, till then I'm using my stupid code as a fallback to the built-in reconnection method.

Remo avatar Aug 03 '15 14:08 Remo