signalr_client icon indicating copy to clipboard operation
signalr_client copied to clipboard

WebSocketException: Connection to #server failed because the connection was not upgraded to websocket

Open apatenotre-chubb opened this issue 1 year ago • 1 comments

Hi,

Since the transition from 1.3.9 to 1.4.0 I can no longer establish a connection with the SignalR server, the error states:

WebSocket connection to #server failed: WebSocketException: Connection to #server was not upgraded to websocket

No settings have been changed, and when I go back to 1.3.9, no more problems.

About settings :

final httpConnectionOptions = HttpConnectionOptions(
      logger: logger,
      logMessageContent: true,
      requestTimeout: _requestTimeOut,
      accessTokenFactory: () => Future.value(
          'Bearer ${Config.serverAuth}|UserAuthorization $userToken'),
      transport: HttpTransportType.WebSockets,
      skipNegotiation: true,
    );
_hubConnection = HubConnectionBuilder()
        .withUrl(Config.signalRHubUrl, options: httpConnectionOptions)
        .withAutomaticReconnect()
        .configureLogging(logger)
        .build();

I noticed since 1.4.0 there is a "0" port, which for me is not normal, namely that I don't specify the connection port in my configuration because it's the default SSL port: 443

image

But even specifying port 443, I have the same error :

image

But it is no longer specified "0" before the hashtag :

image

I think my problem comes from the modification of how the "access_token" went in 1.4.0 :

image

Indeed, in my project I have a double authentication, via an application token (valid for 1 year), and via the user's token (short duration).

apatenotre-chubb avatar Oct 04 '24 12:10 apatenotre-chubb