-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
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
Path not working on 2.x ws server #1000
Comments
The value of the |
Somehow this longer works on 2.x. Could be something else but if I remove the path the client gets a response. Any ideas? A different thing I discovered: the latest bufferutil and utf-8-validate modules are not compatible with ws 2.x. Which versions are exactly compatible? |
If you remove the
|
In In |
Well, I am registering several paths for the express based server. In my case the connection should stay open and be passed to the next ws handler until the path matches. If there is no match express should return a 404 error and close the connection. So the shouldHandle() call should be done first before doing any further checks which could cause an abortConnection() call. |
Express does not handle upgrade (WebSocket) requests so it will never answer with a 404 to an upgrade request. The Node.js HTTP server emits a 'request' event for non upgrade requests and an 'upgrade' event for upgrade requests. The express handler/router is only used when the 'request' event is emitted. Hope this makes sense. |
I see. If several paths are registered then the connection should only be closed if no matching path was found. |
You can register only a single path in the WebSocket server. |
The main problem is that we are using several WebSocket servers with different paths but the same express server instance. This was working fine with ws 1.x. Now the first WebSocket server closes the connection if the path would match the path of the registered second WebSocket server. This is a crucial feature because we extend express to allow ws routes which register a WebSocket server using the route's path. |
You didn't say anything about this! Take a look a this comment on how to make this work with |
Thanks for the link. I refactored my code and now everything works again. |
Awesome. |
So far the following code was working fine on 1.1.2:
It uses a path and express connection. If the path is removed connections are established.
On 2.x the client just returns:
It seems the path is not recognized and therefore the connection never being upgraded.
The text was updated successfully, but these errors were encountered: