New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: Middlewares not executed when setting up with useSocketServer
#261
Comments
useSocketServer
useSocketServer
useSocketServer
I have a similar problem |
Me too |
This is now almost a year old. I am having this again in another project. Using socket.io 4. Ist this project still being maintained? |
Yes, but unfortunately the time we can allocate is limited. I’m planning some refactoring and support for latest socket.io in the near future. |
I am doing some research currently. My setup: Node LTS, express server. The problem is located here:
The middleware is not called, because the socket.io middleware in which it is wrapped is not called. So this might be a problem with the combination socket.io on an express server. I will dig deeper. |
One other suggestion: I am using a custom namespace. It seems like the middleware is namespace-specific: |
Confirmed last statement: Tested with code like this: io.of('/my-namespace')
.use((socket, next) => {
console.log('middleware running with namespace...');
next();
});
io.use((socket, next) => {
console.log('middleware running in general...');
next();
});
useSocketServer(io, {
controllers: [__dirname + '/controllers/*.ctrl.js'],
middlewares: [__dirname + '/middlewares/*.mw.js']
}); leads to following output:
|
I'll propose a solution in a PR |
Closing as this has been resolved in #511 |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
Description
Hi, I wanted to use a middleware for doing authentication.
The problem is: The middleware is never ever being called.
Following setup:
Expected behavior
Middleware code being executed
Actual behavior
Middleware code not being executed
The text was updated successfully, but these errors were encountered: