Skip to content
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

Socket.IO -- catching path on connection #289

Open
septagram opened this issue Dec 6, 2019 · 0 comments
Open

Socket.IO -- catching path on connection #289

septagram opened this issue Dec 6, 2019 · 0 comments

Comments

@septagram
Copy link

septagram commented Dec 6, 2019

In Socket.IO, it's possible to specify the path when initializing socket:

// io mocked with SocketIO from mock-server
const socket = io ('localhost:8080', {
    path: '/hello/world',
}
// Results in connection to localhost:8080/hello/world

However, when connecting to mock-socket server, this path is truncated:

const serverPathInUrl = new Server ('localhost:8080/hello/world')
serverPathInUrl.on ('connection', socket => {
    console.log ('This never gets called')
})

const serverPathSeparate = new Server ('localhost:8080')
serverPathSeparate.on ('connection', socket => {
    console.log (socket.url)
    // 'localhost:8080'
})

const serverPathSpecific = new Server ('localhost:8080' {
    path: '/hello',
})
serverPathSeparate.on ('connection', socket => {
    // Joyfully accepts connections from other paths
})

For an application that employs multiple sockets on the same host but different paths, what can be done to retrieve the path that was used for connection, or to only accept connections on given path?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant