Issue: socket connects to two namespaces

77 views
Skip to first unread message

Sergio Canales

unread,
Dec 5, 2012, 1:23:49 PM12/5/12
to sock...@googlegroups.com
Hi,

After some debugging i figured out something weird, a socket connects to 2 different namespaces, for example:

//client side

    socket = io.connect("http://mydomain.com/TYPE_ONE", socketOptions);


//server side

   io.of("/TYPE_ONE").on("connect", function(socket){
        console.log("Connected to TYPE ONE with id:\t"+socket.id);

   });

   io.of("/TYPE_TWO").on("connect", function(socket){
        console.log("Connected to TYPE TWO with id:\t"+socket.id);

   });


// debug

Connected to TYPE_ONE with id:      1234
Connected to TYPE_TWO with id:       1234

Any ideas what could be causing this or how to avoid it?

Thanks in advance





cendrizzi

unread,
Dec 23, 2012, 3:13:28 PM12/23/12
to sock...@googlegroups.com
Wish someone had responded to this. I'm having the same issue. Any luck?

Sergio Canales

unread,
Dec 23, 2012, 5:04:56 PM12/23/12
to sock...@googlegroups.com
Hey,

I found the issue was that at some point in my code, I was sending a message from the second namespace to that socket, so that made it connect to that namespace.

So socketOfAjoins nmespace A, at some point I did socketOfA.of("B").emit(someMsg);

That made socketOfA join namespace B.

Hope this helps you

S.

Sent from my iPhone


Angel Java Lopez

unread,
Dec 23, 2012, 3:20:19 PM12/23/12
to sock...@googlegroups.com
I'm newbie to namespaces and socket.io .... but, what is the problem?

I guess the socket.id is keep by client connection, not by namespace.

What is the use case that cause a problem? i.e. a use case where same socket.id in different namespaces is a problem

Angel "Java" Lopez
@ajlopez
gh:ajlopez
Reply all
Reply to author
Forward
0 new messages