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

Handle connections to invalid WebSocket routes gracefully #3048

Closed
ThatOneBro opened this issue Oct 16, 2023 · 0 comments · Fixed by #3049
Closed

Handle connections to invalid WebSocket routes gracefully #3048

ThatOneBro opened this issue Oct 16, 2023 · 0 comments · Fixed by #3049
Assignees
Labels
subscriptions Features and fixes related to subscriptions

Comments

@ThatOneBro
Copy link
Member

ThatOneBro commented Oct 16, 2023

Currently we are just destroying the socket (terminating the connection) whenever a route isn't matched against our WebSocket routes in the route map. This results in 5xx errors at the ALB since the ALB gets stuck waiting for a response and eventually times out, leaving the client hanging until timeout and eventual 5xx.

The fix is to send back HTTP/1.1 404 Not Found\r\n\r\n and give a proper HTTP response upon being unable to upgrade. See MDN for more about Upgrade protocol:

If the server decides to upgrade the connection, it sends back a 101 Switching Protocols response status with an Upgrade header that specifies the protocol(s) being switched to. If it does not (or cannot) upgrade the connection, it ignores the Upgrade header and sends back a regular response (for example, a 200 OK).

-- MDN: Protocol upgrade mechanism

@ThatOneBro ThatOneBro self-assigned this Oct 16, 2023
@ThatOneBro ThatOneBro added the subscriptions Features and fixes related to subscriptions label Oct 16, 2023
@ThatOneBro ThatOneBro added this to the November 1, 2023 milestone Oct 16, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
subscriptions Features and fixes related to subscriptions
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant