-
Notifications
You must be signed in to change notification settings - Fork 10.1k
use() middleware is not triggered #4237
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
Comments
I think this relates to:
After reading better those issues I understand that this behavior is caused by the fact that when Would it be possible to still trigger the regex match? I think that would solve these 4 tickets In the meanwhile the solution is to manually declare each namespace |
Hi. I'm adding a middleware on default the namespace. Unfortunately, after adding middleware, io instance stops firing events. Is this the same issue or unrelated? If I remove "use", everything works as expected. Output: io.of("/").use((socket, next) => {
try {
let data = verifyUserToken(socket);
socket.data = data;
next();
} catch (error) {
next(new Error("Socket middleware error"));
}
}); |
@yalcinozer I don't think this is related. Could you add a |
Closed due to inactivity, please reopen if needed. |
Describe the bug
of(/./).use()
middleware is not triggeredwhen using eiows.Serverapparently also if we dont use the eiows.Server module it still shows the same behaviorTo Reproduce
We need three files, 1 server 2 client.
Launch the server with
nodemon server.js
and openlocalhost:5656/1
andlocalhost:5656/2
Now both tabs should be connected to the socket io instance and in the terminal where the server was launched there would be printed
Put the terminal with
nodemon
on one side and thelocalhost:5656/2
tab on the other side with the devtools console openSave the file
server.js
with no changes and nodemon should restart the server, now in the console you will see onlyNow even if you reload the
localhost:5656/2
page the console.log would still not work.NOTE: Sometime it may work, so try to save again it takes some tries. I found that the best way to reproduce is to look at the devtools console and spam
ctrl+s
on theserver.js
file so that nodemon keeps restarting the server until thelocalhost:5656/2
devtools console throws an error saying ws connection cannot be made. When you see the error let the server start and the error should appearSocket.IO server version:
4.4.0
Server
Socket.IO client version:
4.4.0
Client 1
Client 2
Expected behavior
The use() callback that contains the console.log should always be triggered but it is not
Additional context
Please note that the error is caused by this line during the middleware:
io.of('/clients').to(socket.handshake.auth.slug).emit('6', {namespace: socket.nsp.name});
we target
/clients
in this call, the same namespace that is not logged in the console.logThe text was updated successfully, but these errors were encountered: