Skip to content

Access HTTP response when handshake fails #1454

Open
@TheCardinalSystem

Description

@TheCardinalSystem

Is your feature request related to a problem? Please describe.
With WebSocketClient#connectBlocking, a flag is returned to indicate if the connection was successfully established, but there is no way to to obtain further information on the handshake response.

Describe the solution you'd like
I would like to be able to access the HTTP response from a failed handshake, especially the HTTP status code.

Describe alternatives you've considered
I have considered reconfiguring my server to accept all Web Socket connections and to authenticate after the fact, sending headers over the upgraded connection. This would require changing a lot of logic on my server and would be difficult to setup.

Additional context
My server is configured to return certain HTTP status codes when rejecting the Web Socket handshake, such as HTTP 401 for unauthorized, or 400 if certain headers are missing. These status codes are needed on the client side to properly handle a failed handshake.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @TheCardinalSystem

        Issue actions

          Access HTTP response when handshake fails · Issue #1454 · TooTallNate/Java-WebSocket