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

hubConnection.stop() never completes if the connection was stopped during negotiation #110

Open
WolfspiritM opened this issue Feb 19, 2025 · 0 comments

Comments

@WolfspiritM
Copy link

Hello,

We are having the problem that sometimes the hubconnection ends up stuck in a "Disconnecting" state when stopped while retrying. In our case this happens if the app is left in the background and Android seems to pause it. When it gets resumed the app tries to reconnect but we also do a stop at the same time.

2025-02-19 21:11:19.441977: Failed to start the connection: The connection was stopped during negotiation.
2025-02-19 21:11:19.444335: Reconnect attempt failed because of error 'The connection was stopped during negotiation.'.
2025-02-19 21:11:19.444650: Connection left the reconnecting state during reconnect attempt. Done reconnecting.
2025-02-19 21:11:19.444950: HttpConnection.transport is undefined in HttpConnection.stop() because start() failed.
2025-02-19 21:11:19.445173: HttpConnection.stopConnection(Unknown) called while in state ConnectionState.Disconnected.
2025-02-19 21:11:19.445377: Call to HttpConnection.stopConnection(null) was ignored because the connection is already in the disconnected state.

After further investigating it seems to be that the httpconnection is in disconnected state and here:

if (_connectionState == ConnectionState.Disconnected) {
_logger?.finer(
"Call to HttpConnection.stopConnection($error) was ignored because the connection is already in the disconnected state.");
return;
}

It just returns without completing the _stopPromiseCompleter that was created beforehand.
After moving:

if (!_stopPromiseCompleter.isCompleted) _stopPromiseCompleter.complete();

Also into the if statement above it works fine but I'm not sure if that is the correct solution.

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

1 participant