sefidgaran / signalr_client

A Flutter SignalR Client for ASP.NET Core
https://pub.dev/packages/signalr_netcore
MIT License
78 stars 112 forks source link

The underlying connection was closed before the hub handshake could complete #21

Open lohitbura opened 2 years ago

lohitbura commented 2 years ago

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"

clmorales commented 2 years ago

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

chenshaxuanjing commented 2 years ago

same issues, any solution?

chrcao commented 2 years ago

hi @sefidgaran any solution to fix this problem?

sefidgaran commented 2 years ago

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?

chrcao commented 2 years ago

hi @sefidgaran it is not working.

MathiasTP commented 2 years ago

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.

aminesnip commented 2 years ago

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

dumptyhumpty2014gmail commented 2 years ago

In my case I set correct port that solved this problem

ingvilow commented 2 years ago

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

ycy1164656 commented 2 years ago

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.