Skip to content

[5.2] Close the backend request when the client leaves before the WebSocket upgrade completes - #162

Merged
tsegismont merged 1 commit into
5.2from
backport/156-to-5.2
Oct 20, 2026
Merged

tsegismont merged 1 commit into
5.2from
backport/156-to-5.2

Conversation

@tsegismont

Copy link
Copy Markdown
Member

Backport of #156 to 5.2
Cherry-picked commit: fef6e0a

… upgrade completes (#156)

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.

(cherry picked from commit fef6e0a)
Signed-off-by: Thomas Segismont <tsegismont@gmail.com>
@tsegismont
tsegismont merged commit 4ae1901 into 5.2 Oct 20, 2026
5 checks passed
@tsegismont
tsegismont deleted the backport/156-to-5.2 branch October 20, 2026 09:47
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

Successfully merging this pull request may close these issues.

2 participants