Disconnect is not fired on root namespace #1805
-
Hello, To preface i'm not sure if this is a bug or intended behaviour but basically from my understanding when socket-io client creates any N number of namespaces, they all share the same WS connection. In my application, I have two events
When the user is connected, "Root connection established" is logged to console. If the user is authenticated, "Root connection is established" followed by "CONNECTED!!" is logged on to console. What i take from this is that the connect on root namespace represents the WS connection in which /notify namespace uses. Maybe I'm understanding this wrong. Now I test the "disconnect" event. My expectations are that "disconnect" event on root namespace will always fire.
However, 'disconnected root' is never logged, regardless if user is authenticated or not (although i dont think its important detail here). Only 'disconnected namespace' is logged. Is this a bug? If 'Root connection established' is logged shouldn't 'disconnected root' also be logged? The reason i ask is that I want to keep track of the number of WS connections. If there are say 10 namespaces, I don't want to log 10 connections if they are all sharing the same WS connection. I thought I could keep track of WS connection by looking at "connected" event on root namespace, but the "disconnect" namespace behaviour makes me a bit confused. Anyone have any thoughts on this? Thank |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
There is no concept of a "root" namespace, this is actually an outdated thing that existed in older versions of Socket.IO. Current versions treat all namespaces equal, and you can connect and disconnect from each namespace independently. |
Beta Was this translation helpful? Give feedback.
There is no concept of a "root" namespace, this is actually an outdated thing that existed in older versions of Socket.IO. Current versions treat all namespaces equal, and you can connect and disconnect from each namespace independently.