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

sometimes get an error : future was called on null at hubconnection.start(). In the line await _handshakeCompleter.future #6

Open
Adilkp796 opened this issue Mar 5, 2019 · 6 comments

Comments

@Adilkp796
Copy link

Adilkp796 commented Mar 5, 2019

Some times get error in hubconnection.start() method with a message future was called on null .The error is exactly on _handshakeCompleter.future .How can resolve it ??

@Schaeri
Copy link

Schaeri commented Apr 5, 2019

We have the same problem (Version 0.1.5). I look at the code and see the following problem:
In the start method of the class HubConnection the completer gets instantiated on line 102. After that the code await for the start of the connection. During this period the method _processHandshakeResponse gets called and set the _handshakeCompleter to null. Then the await on line 117 will fail with a null reference exception.
The simplest fix for that is to make a null check on line 117. But I can not say if that is correct.
Are there any plans to fix this issue soon?

@soernt soernt closed this as completed Apr 6, 2019
@soernt soernt reopened this Apr 6, 2019
@davbaron
Copy link

davbaron commented Apr 8, 2019

I am getting the same issue, though it is intermittent, meaning, sometimes it throws the error (null _handshakeCompleter) and sometimes it works. I will post a separate issue on my overall issue (client and/or server not working). I cannot discern a pattern of failure. I would like to say that it 'usually' happens while my VS 2019 project is in run/debug mode, but I can't say exactly what percentage 'usually' is. It certainly fails when not debugging as well. The issue is not, at least for me, binary either - besides either connecting successfully or failing with a null _handshakeCompleter, I also get failures for 404 (remote server not found). This is with no changes to code. The same code that succeeds will then fail with a 404, which is somewhat hard to understand.

I will also add however, that even when it does work, and I 'print' out the successful connected state, when I 'close' the Flutter screen (go back to a prior screen), I never get an 'immediate' print out of 'connection closed'. Instead I have added the dispose() method to my screen, and if the connection is 'Connected' then I issue a .stop() call. Seems to work.

@firatcetiner
Copy link

firatcetiner commented Apr 12, 2020

Same issue here. Following the exact instruction as the Example Project.

@digitalkirkley
Copy link

I get same intermittent issue. To resolve (hub_connection line: 117):
if (_handshakeCompleter != null)
await _handshakeCompleter.future;
This seems to work.

@KThen
Copy link

KThen commented Oct 11, 2020

I've never worked with SignalR before but I'm curious, is this an issue to be solved, or does it only occur during flutter restart/hot reload? If it only happens during flutter restart/hot reload I'm not that worried, but if it will occur during production then I would like to know what the proper solution is.

I am trying to evaluate @digitalkirkley 's solution but I'm not sure tampering with the source code is the right way.

@firatcetiner
Copy link

I got this error roughly 6 months ago and back then I quit using SignalR and started to build my own solution with basic socket programming. However, after a long while I decided to give an another chance to SignalR and now it's working like a charm. If this issue still occures, I think it doesn't related to this package at all.

centos94 pushed a commit to centos94/signalr_client that referenced this issue Aug 10, 2021
Adding support for flutter for web and fixing bug with connectionToken in url query
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

7 participants