Skip to content

Using middlewares on application level #3745

Answered by darrachequesne
serp-ya asked this question in Q&A
Discussion options

You must be logged in to vote

This was indeed the behavior in Socket.IO v2: even when using a namespace (io.connect('/admin')), you were implicitly connected to the main namespace (/), which is quite surprising.

This should not happen anymore with Socket.IO v3.

See also: https://socket.io/docs/v3/migrating-from-2-x-to-3-0/#No-more-implicit-connection-to-the-default-namespace

Regarding the dynamic namespace feature, the middleware registered here:

websocket.of(/^\/\w+$/).use((socket, next) => {
  console.log('regexp');
  next();
});

is indeed registered on each child namespace. I will update the documentation about this.

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@serp-ya
Comment options

Answer selected by serp-ya
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants