Skip to content

Cancelling WebSocket connect leaves the HTTP upgrade socket open #4433

Backlog

Description

@CryoThrust

Problem

Both JdkWebSocketTransport.connect and OkHttpWebSocketTransport.connect create a Mono without cancellation cleanup. Disposing the subscription while the HTTP upgrade is stalled leaves the socket open until a timeout or a later server response, even though the caller no longer needs the connection.

Evidence

On main@5a315a9af, real loopback servers accept the upgrade request and intentionally withhold the handshake response. After disposing the connection subscription, both JDK and OkHttp connections remain open until the server's five-second read deadline. Additional JDK future regressions show pending handshake futures are not cancelled and an uncancellable future's late socket is not aborted. The successful connection ownership control passes.

Proposed scope

Register cleanup on subscription cancellation, cancel the JDK handshake future/OkHttp WebSocket, and abort an undelivered JDK socket returned after cancellation. Preserve delivered-connection ownership, error mapping, proxy configuration and message processing. Tests use local sockets/mocked futures, with no live model provider or credentials.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions