Socket.io-client: v3 disconnection of socket seems to close underlying connection.

Created on 16 Nov 2020  路  4Comments  路  Source: socketio/socket.io-client

You want to:

  • [x] report a bug
  • [ ] request a feature

Current behaviour

After I upgraded to v3, when I call socket.disconnect() on either of the client or server sides, it seems that the Manager's underlying connection is also being closed- all other sockets using the same manager / underlying connection also get disconnected.

I don't know where to file this issue. Maybe it has root in engine.io v4?

Here's a diff of my project during the upgrade. I apologize that it contains some unrelated changes as well. The main thing I mean to highlight is that I didn't make any changes to how I setup and manage connections (you can cmd+F for "disconnect", "close", "io.socket").

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

Please see this jsfiddle.

Expected behaviour

The v2 behaviour is that calling socket.close() on the clientside and on the serverside should only close that socket when a manager has multiple namespaces- it should not close every multiplexed socket under that socket's manger.

Setup

  • OS: Windows 10
  • browser: Chrome 86.0
  • socket.io version: 3.0.0

Observe behaviour difference when using socket.io v2 instead.

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

All 4 comments

I spent a bunch of time debugging my own code thinking I broke something :')

Looking forward to the fix! And thanks again for your hard work in starting v3.

The "connecting" event is never fired on socket connection and doesn't fill the connecting array in manager:
https://github.com/socketio/socket.io-client/blame/master/lib/manager.ts#L599

When _destroy is called if (this.connecting.length) return; this._close(); will always close the connection.

I don't see an issue in the client code. Maybe some bug on server side? In the server code I couldn't find any event named "connecting". Maybe that's the issue?

Here is the commit that removes the emit of "connecting".

https://github.com/socketio/socket.io-client/commit/b60e909039d4bbb979d32ec86ac16c5398526b44#diff-f0e64910289a49966c99ceadaa5637404e3439ec0812a4bdb7003fe1e5a33d1c

@darrachequesne Could you please check this issue.

@david-fong I could indeed reproduce the issue, thanks a lot for the detailed steps :+1:

This should be fixed by https://github.com/socketio/socket.io-client/commit/f8f60fc860f51aa6465fc32dd9275a8e1d22f05d (included in [email protected]).

Again, thanks for the detailed report, that really helps!

Was this page helpful?
0 / 5 - 0 ratings