Skip to content

WebSocket: backend request left open when the client leaves before the upgrade completes #155

Closed

Description

@zenios

Version

5.2.1 (also current main)

Context

The client and backend sockets of a proxied WebSocket are only joined in ReverseProxy.Proxy#sendResponse once the
backend answers 101. Nothing watches the client connection before that, so a client that goes away during the
upgrade leaves the request to the backend open:

  1. Backend has not answered yet: the backend connection stays open for as long as the backend does not answer
    (indefinitely for a backend that never answers).
  2. Backend answers 101 after the client left: proxiedRequest().toNetSocket() fails, the failure branch prints
    Handle this case and a stack trace to System.err, and the backend socket is never closed.
  3. Client already gone when the origin is resolved (e.g. an OriginRequestProvider doing an async lookup): the
    upgrade is still sent to the backend.

Proxied HTTP requests do not have this problem: ProxiedRequest#sendRequest resets the backend request from the
client response's exception handler. The WebSocket branch in ReverseProxy.Proxy#sendRequest calls
request.connect() directly and does not set it.

Steps to reproduce

  1. Proxy to a backend that reads the upgrade request and never answers.
  2. Send a WebSocket upgrade through the proxy, then close the client connection.
  3. The backend connection is never closed.

Do you have a reproducer?

Yes, two tests in WebSocketTest in the linked PR; both fail on main (the first by timing out, the second with the
upgrade reaching the backend).

Activity

  1. self-assigned this
    on Oct 20, 2026
  2. modified the milestone: 5.2.2 on Oct 20, 2026
  3. tsegismont commented on Oct 20, 2026

    @tsegismont
    Member

    Fixed by #162

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions