signalr_client icon indicating copy to clipboard operation
signalr_client copied to clipboard

The underlying connection was closed before the hub handshake could complete

Open lohitbura opened this issue 2 years ago • 10 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"

lohitbura avatar Mar 17 '22 13:03 lohitbura

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

clmorales avatar Apr 21 '22 02:04 clmorales

same issues, any solution?

chenshaxuanjing avatar Apr 29 '22 07:04 chenshaxuanjing

hi @sefidgaran any solution to fix this problem?

chrcao avatar May 08 '22 14:05 chrcao

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?

sefidgaran avatar May 19 '22 02:05 sefidgaran

hi @sefidgaran it is not working.

chrcao avatar May 19 '22 07:05 chrcao

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.

MathiasTP avatar May 20 '22 12:05 MathiasTP

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

aminesnip avatar May 26 '22 19:05 aminesnip

In my case I set correct port that solved this problem

dumptyhumpty2014gmail avatar Aug 04 '22 07:08 dumptyhumpty2014gmail

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

ingvilow avatar Aug 12 '22 10:08 ingvilow

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.

ycy1164656 avatar Aug 26 '22 02:08 ycy1164656