Skip to content

WebSocketException: Connection to '<url>' was not upgraded to websocket, HTTP status code: 403 #105

@pgulegin

Description

@pgulegin

Using version 1.3.9, everything was working as expected.
1.4.0 appears to have this breaking change.

In the code/exception below, 'url' denotes the original url I used.
However, 'url_modified' is my original url, but it has been modified to include a port number and a hashtag.

So, if my original url was something like... https://www.google.com/Channels/Support
Then, the new url is... https://www.google.com:0/Channels/Support#

Code

    connection = HubConnectionBuilder()
        .withUrl('<url>',
            options: HttpConnectionOptions(
              accessTokenFactory: () async {
                return fetchAccessToken();
              },
              skipNegotiation: true,
              transport: HttpTransportType.WebSockets,
              logger: _logger,
              logMessageContent: true,
            ))
        .withAutomaticReconnect(retryDelays: [1, 3000, 10000, 30000]).build();

Exception

[ChatPageViewModel] WebSocket try connecting to 'wss://<url>'.
flutter: WebSocket try connecting to 'wss://<url>'.
flutter: 2025-01-20 17:24:23.514104 ══╡ EXCEPTION CAUGHT BY CHATPAGEVIEWMODEL ╞═════════════════════════════════════════════════════════
The following _Exception was thrown WebSocket connection to 'wss://<url>'
failed: WebSocketException: Connection to '<url_modified>' was not
upgraded to websocket, HTTP status code: 403:
Exception
════════════════════════════════════════════════════════════════════════════════════════════════════
flutter: WebSocket connection to 'wss://<url>' failed: WebSocketException: Connection to '<url_modified>' was not upgraded to websocket, HTTP status code: 403
flutter: 2025-01-20 17:24:23.514711 Another exception was thrown: Exception
flutter: Failed to start the connection: WebSocketException: Connection to '<url_modified>' was not upgraded to websocket, HTTP status code: 403
flutter: 2025-01-20 17:24:23.515032 _ChatStore() startConnection() WebSocketException: Connection to '<url_modified>' was not upgraded to websocket, HTTP status code: 403

Thank you.

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

    Issue actions