Open nayefradwi opened 1 year ago
After investigating this issue, It seems that the handshake request is being sent without the authorization header, which in the backend I am working with is required to establish the connection.
I tried to do something like this but still did not fix the issue
MessageHeaders headers = MessageHeaders();
headers.setHeaderValue(AuthInterceptor.authorizedHeader,
"Bearer ${GetIt.I<ShopperApiClient>().accessToken}");
HubConnection connection = HubConnectionBuilder()
.withUrl(
AppConfig.signalrUrl,
options: HttpConnectionOptions(
logger: transportProtLogger,
logMessageContent: !AppConfig.isProd,
headers: headers,
skipNegotiation: true,
requestTimeout: 120000,
transport: HttpTransportType.WebSockets,
accessTokenFactory: () async {
String accessToken = GetIt.I<ShopperApiClient>().accessToken;
return accessToken;
},
),
)
.withAutomaticReconnect(retryDelays: delaysInMilliSeconds)
.configureLogging(hubProtLogger)
.withHubProtocol(JsonHubProtocol())
.build();
return connection;
I have noticed that the first request and the negotiation both have the access token in their headers, just the handshake request does not have it and this causes the error "The underlying connection was closed before the hub handshake could complete."
I am facing an issue where I am unable to connect to signalr hub using this package but I am able to connect using a different (not flutter) signalR client.
At first I thought that it could be an issue with the certificate, but i have added
and it is being called, I am not sure what is the issue and I am struggling to find out please help. Here are the logs:
this is how I am building the connection:
it works with long polling but not websockets