Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Connect event not fired for namespaced sockets #255

sentientmatter opened this Issue · 10 comments

9 participants


When setting up namespaced sockets, the connect event doesn't seem to be firing. This may only be occuring on ports other than 80 (I'm not able to test websockets on port 80).

This code works as expected and the callback fires:

var socket = io.connect('');
socket.on('connect', function () {
    //Works just fine

But when the namespace is added, the callback never fires:

var socket = io.connect('');
socket.on('connect', function () {
    //Never gets here

Again I suspect this occurs when the port and namespace are specified, but I haven't been able to test that theory.


Yep latest version, 0.7.4 client and 0.7.7 server. I tested on port 80 just now and still nothing...the connect event isn't fired if connecting with a namespace, tested on Firefox 5 using long polling and Chrome using websockets. I also noticed that my server side .on('connection') isn't being fired either, am I just missing something? Here is code I'm using:


var stuff = io.connect('');
stuff.on('connect', function () {
    // socket connected (never gets fired)

stuff.on('hello', function(){
    //Never gets here either
    console.log('got hello');

And Server:

var io = require(''),
express = require('express');

var app = express.createServer(), io = io.listen(app);


io.of('/stuff').on('connection', function(socket){
    //Never gets fired
    console.log('user connected');


yep. still not working here.
latest version, 0.7.4 client and 0.7.8 server

I think the unit test use disconnect,but our scope maybe much more complex,our network interrupted or else.
(for me, I transfer a lot of data by, every 2.5 min or less , the server log said "transport end, then clear the timeout ... or else ,reconnection come." )

And I found that, when the reconnection called, the clients get a new ID.


Could it be simply that subsequent connections to the same host don't fire a 'connection' event?


They connection event is only fired if the client sends a connect packet to the server.

I suspect that

var socket = io.connect('');
socket.of('/namespace').on('connect', function () {
    //Never gets here

does work?


I have version 0.9.6 of the client installed. The following still does not work for me:

var socket = io.connect('/index', { port: 6373 });
socket.on('connect', function () {
    // Never gets here

However, if I connect to the default namespace first, and then connect to /index, it works:

var socket1 = io.connect('', { port: 6373 });
socket1.on('connect', function () {
    // We get here
    var socket2 = io.connect('/index', { port: 6373 });
    socket2.on('connect', function () {
        // We also get here

Hopefully that narrows this down somehow.

@colthreepv client still haves this issue @ version 0.9.16 ...


+1, this is a big issue for me as well. It seems as though if I only pass a url to connect() things fire off correctly, but adding the options object causes issues.


The following fires events:
App.socket = io.connect('', {secure: true, resource: "3001/"});

The following doesn't fire events:
App.socket = io.connect('', {secure: true, resource: "3001/"});

Do I have the first parameter incorrect? What exactly am I supposed to pass in?


The following did a trick for me with: "^0.9.16"

io.connect("http:///localhost:4000", {'force new connection': true});

Now 'connect' event fires consistently and there is no re-use.

I figured out this option by examining line: 192
Since I can't even find this io.js file in github, I think there is refactoring in future releases, and this option might not work.

At least this might be helpful to somebody who will take this temporary work around.

@rauchg rauchg closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.