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

Connecting to custom namespace connects to default namespace, too #3089

Closed
1 of 2 tasks
MickL opened this issue Oct 20, 2017 · 4 comments
Closed
1 of 2 tasks

Connecting to custom namespace connects to default namespace, too #3089

MickL opened this issue Oct 20, 2017 · 4 comments
Milestone

Comments

@MickL
Copy link
Contributor

MickL commented Oct 20, 2017

You want to:

  • report a bug
  • request a feature

Current behaviour

const adminSocket = io('/admin', { forceNew: true }); will connect to Namespace "/" AND "/admin".

Using this will connect to default namespace two times:

const socket = io();
const adminSocket = io('/admin', { forceNew: true });

Im not sure if this is by design but if yes, it did not found it in the documentation.

Expected behaviour

Connecting to a namespace should not connect to default namespace

Setup

  • socket.io version: 2.0.3
@MickL MickL changed the title Connecting to customt namespace connects to default namespace, too Connecting to custom namespace connects to default namespace, too Oct 20, 2017
@akashada
Copy link

its by design, discussion can be found in #2124 and #2342 . the description about it in the docs is still fuzzy

@cryptogearbox
Copy link

cryptogearbox commented Mar 30, 2018

Is it also by design that when the root namespace disconnects all other related namespace disconnects also?

For example, these two IDs, yRvGKh9Svkp_yvvCAAAA and /otherNamepace#yRvGKh9Svkp_yvvCAAAA when the root yRvGKh9Svkp_yvvCAAAA ID is disconnected, it also disconnects the other namespace too.

EDIT: This is false. It was an error in my code. Just thought I'd follow up.

@murrayju
Copy link

murrayju commented Apr 23, 2018

The biggest problem that I have with this is, if the default namespace has some middleware that might emit an error (e.g. authentication), when the client connects to some other namespace this middleware will (correctly?) stop the connection from succeeding, but it does not fire the error event on the namespace. So to the user of the namespace, it looks like the thing is just hanging, and neither connects nor disconnects.

@darrachequesne
Copy link
Member

For future readers: this was fixed in Socket.IO v3, the implicit connection to the default namespace was removed.

Documentation: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/#No-more-implicit-connection-to-the-default-namespace

@darrachequesne darrachequesne added this to the 3.0.0 milestone Feb 20, 2021
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

5 participants