Skip to content

What is the use of path for socket.io, how is that different from custom namespace #4679

Answered by darrachequesne
Zeus-Iqd asked this question in Q&A
Discussion options

You must be logged in to vote

Hi! The path option refers to the request path. With path: '/mypath', you will see in your network panel HTTP requests like:

GET http://myserver/mypath/?EIO=4&...'

The path option defaults to /socket.io/:

GET http://myserver/socket.io/?EIO=4&...'

Reference: https://socket.io/docs/v4/client-options/#path

On the other hand, the namespace (the /admin in your example) is the part of your application you'd like to connect to. It provides a way to split your application logic into independent modules, while using the same WebSocket connection under the hood (multiplexing).

Reference: https://socket.io/docs/v4/namespaces/

With io('http://myserver/admin'), you reach to /admin namespace, with io…

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by darrachequesne
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