Repository navigation
Conversation
… upgrade completes
Motivation:
The client and backend sockets of a proxied WebSocket are only joined once the backend answers 101. A client that
closes its connection before that leaves the request to the backend open: for as long as the backend does not answer,
and for good when the backend answers 101 after the client has gone, since the client connection can no longer be
turned into a socket ("Handle this case"). A client that is already gone when the origin is resolved still gets its
upgrade sent to the backend.
Changes:
Reset the backend request when the client response reports the connection closed before anything was written, the
same way proxied HTTP requests are reset. Fail without sending the upgrade when the client connection is already
closed once the origin is resolved. Close the backend socket instead of printing a stack trace when the client
connection cannot be upgraded after a 101.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #155
Motivation:
The client and backend sockets of a proxied WebSocket are only joined once the backend answers 101. A client that
closes its connection before that leaves the request to the backend open: for as long as the backend does not answer,
and for good when the backend answers 101 after the client has gone ("Handle this case"). A client that is already
gone when the origin is resolved still gets its upgrade sent to the backend.
Changes:
ProxiedRequest#sendRequestdoes forproxied HTTP requests.
HttpServerResponsecalls it with a closed exception only while nothing has been written,so it does not fire once the connection has been upgraded.
closed(), so a client that closed before the origin was resolved (or betweenthe two) fails the request without sending the upgrade.
trace.
WebSocketTest: a client closing during a pending upgrade closes the backend connection, and a clientgone before the origin is resolved sends no upgrade. Both fail without the change.