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

Using socket.disconnect(false) on root namespace breaks all communication #2433

Closed
manad777 opened this issue Feb 6, 2016 · 4 comments
Closed

Comments

@manad777
Copy link

manad777 commented Feb 6, 2016

I've got a very short example here: https://github.com/manad777/sio-root-bug

Run it, and it should work fine. However, uncomment lines 32-34 in index.js, and all communication stops silently.

The lines in question are:

io.of('/').on('connect', function(socket) {
   socket.disconnect(false);
});

Essentially, I can use socket.disconnect(false) on any namespace, but if I use it on the root namespace, all communication stops.

@LordMajestros
Copy link

See https://github.com/socketio/socket.io/pull/2415/files and #2400 that seems to be the intended behaviour.
If you call with true it disconnects the socket with false it closes the namespace.

@manad777
Copy link
Author

You misunderstand the issue I'm reporting.

I know that disconnecting the socket from a namespace (disconnect(false)) closes that socket's connection to the namespace. That's my goal.

What I'm saying is that disconnecting the socket from the root namespace breaks other namespaces as well. Please refer to my example, it's very short and to the point. The client connects to 3 namespaces, if you include root. Disconnecting from root should not prevent the transmission of events on the other 2 namespaces, and yet it does. Root namespace has a special behavior, different from all the other namespaces, this should be viewed as an implementation bug. At the very least, the documentation should me mentioning this issue.

@LordMajestros
Copy link

Yes, I agree that the documentation should mentions this.
I think it makes sense from the perspective that the root namespace is indeed the root.
The way clients connect when they connect to a non default(root) namespace is that they connect first to the root namespace then to the specified namespace. It follows then that if you close the root namespace it closes other namespaces(stems and branches).

@darrachequesne
Copy link
Member

That issue was closed automatically. Please check if your issue is fixed with the latest release, and reopen if needed (with a fiddle reproducing the issue if possible).

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

3 participants