sefidgaran / signalr_client

A Flutter SignalR Client for ASP.NET Core

Home Page:https://pub.dev/packages/signalr_netcore

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

The underlying connection was closed before the hub handshake could complete

lohitbura opened this issue · comments

I implemented the code . It's Working in some devices . But In Some of the devices it's showing the following error .
I guess the main reason is that connection is not establishing.

"The underlying connection was closed before the hub handshake could complete"

I was having the same issue and I managed to fixed it setting the transport in options to LongPolling

hubConnection = HubConnectionBuilder()
.withUrl(serverUrl,
options: HttpConnectionOptions(
transport: HttpTransportType.LongPolling,
))

same issues, any solution?

hi @sefidgaran
any solution to fix this problem?

I was having the same issue and I managed to fixed it setting the transport in options to LongPolling

hubConnection = HubConnectionBuilder() .withUrl(serverUrl, options: HttpConnectionOptions( transport: HttpTransportType.LongPolling, ))

Hi @chrcao
Have you tried the solution above?

hi @sefidgaran
it is not working.

I can confirm that i get the error aswell. I am on flutter 3.0.0.
If i try to use the transport option longpolling i will get an error aswell.

I am getting this error as well.
When I test locally on windows it works very well, but the error appears when I publish on the linux server.
Any solution to fix this problem ?.

In my case I set correct port that solved this problem

I was struggiling with the same ussue, but in my case API-devs created accessToken to API and I used it wrong. So as I understood SignalR package put in headers access tokens and if your API-devs configure token as "&authinticate=tokens_long_string_key_example", it is not gonna work, because server can't negotiate (I didn't remember verbatim the error in this case, but it will be something about negotiation). In my case to resolve this issue I should have in request body access-token instead of authinticate. Also really highly reccomend to use this Logger package logging: any, it is real time-saver

commented

In my case, it's the Authorization that caused this problem, in detail, every step needs to add Authorization in the header including during websocket handshaking. Hope this would help.