Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
apatenotre-chubb opened this issue Oct 4, 2024 · 6 comments

Comments

@apatenotre-chubb
Copy link

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).

@autocar
Copy link

autocar commented Oct 10, 2024

I had the same problem when I upgraded to 1.4.0 without changing any settings. So I went back to 1.3.9.

@Aruljebaraj
Copy link

@autocar is it working after downgrading to 1.3.9?

@hoaq139
Copy link

hoaq139 commented Nov 22, 2024

any update for this problem :(

@Aruljebaraj
Copy link

@hoaq139 use 1.3.9 it's working

@SAGARSURI
Copy link

So instead of adding 'Bearer' string with the token. Just send the token in accessTokenFactory and it will work.

@erturks
Copy link

erturks commented Jan 9, 2025

So instead of adding 'Bearer' string with the token. Just send the token in accessTokenFactory and it will work.

In version 1.4.0, the connection is not established whether or not "Bearer" is added as a header to the accessTokenFactory parameter.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants