-
Notifications
You must be signed in to change notification settings - Fork 10.1k
Closed
Labels
bugSomething isn't workingSomething isn't working
Milestone
Description
You want to:
- report a bug
- request a feature
Current behaviour
When using a custom namespace with a middleware the server gets a 'connection' event, but the client does not receive 'connect' event.
This works:
io.use((socket, next) => {
console.log('middleware running...');
next();
}).on('connection', socket => {
console.log('client connected');
});
This does not work:
// Following works, but client does not receive 'connect' or 'connection':
io.of('/admin').use((socket, next) => {
console.log('middleware running...');
next();
}).on('connection', socket => {
console.log('client connected');
});
Sitenotes
Also very strange: If i do the following code then also the default-namespace does not emit any 'connect' event even tho the middleware from /admin is not running.
io.on('connection', socket => {
console.log('client connected');
});
io.of('/admin').use((socket, next) => {
console.log('middleware running...');
next();
}).on('connection', socket => {
console.log('client connected');
});
To fix this i have to add .use((socket, next) => { next(); }) to default namespace. But still /admin does not emit 'connect'.
Steps to reproduce (if the current behaviour is a bug)
Please see above
Expected behaviour
On connection, client should receive 'connect'
Setup
- OS: macOS Sierra 10.12.6
- browser: Chrome
- Node: v8.2.1
- NPM: 5.4.2
- socket.io version: 2.0.3
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working