diff --git a/lib/socket.js b/lib/socket.js index 82b675497c..e6febefcf5 100644 --- a/lib/socket.js +++ b/lib/socket.js @@ -71,11 +71,11 @@ Socket.prototype.open = Socket.prototype.connect = function(){ var io = this.io; io.open(); // ensure open - if ('open' == this.io.readyState) this.onopen(); this.subs = [ on(io, 'open', bind(this, 'onopen')), on(io, 'error', bind(this, 'onerror')) ]; + if ('open' == this.io.readyState) this.onopen(); }; /** diff --git a/test/connection.js b/test/connection.js index a6e9bf2a1f..0fac3ead1c 100644 --- a/test/connection.js +++ b/test/connection.js @@ -31,6 +31,19 @@ describe('connection', function() { }); }); + it('should connect to a namespace after connection established', function(done) { + var manager = io.Manager(); + var socket = manager.socket('/'); + socket.on('connect', function(){ + var foo = manager.socket('/foo'); + foo.on('connect', function(){ + foo.close(); + socket.close(); + done(); + }); + }); + }); + if (!global.Blob && !global.ArrayBuffer) { it('should get base64 data as a last resort', function(done) { socket.on('takebin', function(a) {