Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,10 @@ Client.prototype.setup = function(){

Client.prototype.connect = function(name){
debug('connecting to namespace %s', name);
if (!this.server.nsps[name]) {
this.packet({ type: parser.ERROR, nsp: name, data : 'Invalid namespace'});
return;
}
var nsp = this.server.of(name);
if ('/' != name && !this.nsps['/']) {
this.connectBuffer.push(name);
Expand Down
14 changes: 14 additions & 0 deletions test/socket.io.js
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,8 @@ describe('socket.io', function(){
var srv = http();
var sio = io(srv);
srv.listen(function(){
sio.of('/chat');
sio.of('/news');
var chat = client(srv, '/chat');
var news = client(srv, '/news');
var total = 2;
Expand Down Expand Up @@ -491,6 +493,18 @@ describe('socket.io', function(){
});
});
});

it('should return error connecting to non-existent namespace', function(done){
var srv = http();
var sio = io(srv);
srv.listen(function(){
var socket = client(srv,'/doesnotexist');
socket.on('error', function(err) {
expect(err).to.be('Invalid namespace');
done();
});
});
});
});

describe('socket', function(){
Expand Down