Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Client reconnect to server doesn't function as instructed. #1067

Closed
1 of 2 tasks
ethernetweb opened this issue Feb 9, 2017 · 7 comments
Closed
1 of 2 tasks

Client reconnect to server doesn't function as instructed. #1067

ethernetweb opened this issue Feb 9, 2017 · 7 comments

Comments

@ethernetweb
Copy link

ethernetweb commented Feb 9, 2017

Note: for support questions, please use one of these channels: stackoverflow or slack

You want to:

  • report a bug
  • request a feature

Current behaviour

I hesitate to bring up what appears to be an old issue that was resolved but I'm now experiencing it in a new version.
I have a socket.io server and a socket.io-client
Both version 1.7.2

When the server calls socket.disconnect(), the client will disconnect but not reconnect, even with the option of reconnection:true
I have attempted to use a disconnect handler client-side to call socket.io.reconnect() but this does nothing.
The socket object reports skipReconnect = true after being disconnected by the server.

Server side disconnect event: server namespace disconnect
Client side disconnect event: io server disconnect

Steps to reproduce (if the current behaviour is a bug)

  1. Client connection to server. Established OK.
  2. Server calls socket.disconnect(); Both client and server close the connection and event handlers discover it.
  3. Client will not reconnect automatically, even with reconnection:true or directly calling socket.io.reconnect();

https://github.com/ethernetweb/socket.io-fiddle/

Note: the best way to get a quick answer is to provide a failing test case, by forking the following fiddle for example.

Expected behaviour

With the option of reconnection:true, client should attempt a reconnect with established socket object within the reconnectionDelay time-frame.

Setup

  • OS: Debian 8.7
  • browser: not applicable
  • socket.io version: 1.7.2

Other information (e.g. stacktraces, related issues, suggestions how to fix)

@centrual
Copy link

I have same issue too.

@akleiner2
Copy link

+1

@kmyllyvi
Copy link

I have this issue also. Has anyone found a workaround to reconnect. I get the 'reconnect' event but the connection is not established. Calling open() or connect() hasn't helped.

Also the timeout value doesn't seem to correlate to actual timeout at least when running on Android/iOS webview (Angular2 webapp). Socket disconnects after latest 2-3min of inactivity even my timeout on client side is set to 18000000 (30min if I'm not mistaken).

@darrachequesne
Copy link
Member

@ethernetweb you should be able to reconnect manually with socket.connect().

I guess it makes sense not to automatically reconnect by default, since it is a deliberate action from the server.

@kmyllyvi
Copy link

kmyllyvi commented Apr 26, 2017

Yes you might be right, thanks. I managed to connect manually after idle disconnect.

Like about so:

Init =>

    this.socket = io.connect({
        path: '/socket.io',
        reconnection: false,
        autoConnect: false,
    });
    this.socket.open();

----- subscribe to disconnect event ------

    this.socket.on('disconnect', () =>  {
        // After disconnected connect/open socket again
        this.socket.open();
    });

----- subscribe to connect event to do your magic ------

    this.socket.on('connect', () => {
        // socket (re/)connected, if the socket was disconnected do stuff accordingly...
        }
    });

@bogdancochioras
Copy link

after rebooting my master server, the client server reconnect is not called and calling after disconnecting and calling connect manually does not connect, same problem as @kmyllyvi

@darrachequesne
Copy link
Member

@bogdancochioras could you please open a new issue and provide some code reproducing the issue please?

Closing this one, see my answer below.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants