-
Notifications
You must be signed in to change notification settings - Fork 10.3k
SignalR Core Abort() leads to undefined state #21422
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
Comments
I edited my post to say that the client does actually try to reconnect sometimes. For the first five or so tries the client didn't reconnect, but today it sometimes tries to reconnect. This is even worse as it's sporadic. It is extremely difficult to come up with code that works reliably with how this works atm and I'd be thrilled if this could get fixed. It is absolutely mandatory that the server can close a connection reliably due to privacy reasons (a user logging out should not receive any data after that point). Please classify this as a high impact bug. Thanks. |
@Tommigun1980 can you provide a sample? It will help use reproduce the problem. Those code snippets are helpful but don't really show how the application is aborting the socket. A few comments:
See this document that explains how to get logs https://docs.microsoft.com/en-us/aspnet/core/signalr/diagnostics?view=aspnetcore-3.1 @halter73 maybe a bug in the reconnect logic. |
I've noticed that HubConnectionContext.Abort() usually doesn't result in the close message (which contains Since we do want to abort the underlying the connection when Abort() is called, ensuring the client gets the close message is a little tricky. It would probably involve flushing the message, and then waiting for the ConnectionClosed token to fire with a timeout that aborts the underlying connection if the client doesn't close the connection itself quickly enough in response to the close message. Another option is to always allow the client to reconnect after HubConnectionContext.Abort() is called, so at least the behavior is consistent whether or not the close message is received.
This shouldn't happen. Client logs and/or a sample would help a lot.
Stopping the connection on the client while in the Reconnecting state should work fine. Client logs and/or a sample would likely help diagnose what's going on here too. |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate. See our Issue Management Policies for more information. |
That seems like something we should fix. |
This issue has been automatically marked as stale because it has been marked as requiring author feedback but has not had any activity for 4 days. It will be closed if no further activity occurs within 3 days of this comment. If it is closed, feel free to comment when you are able to provide the additional information and we will re-investigate. See our Issue Management Policies for more information. |
Thanks for looking into this! I see it's tagged into 5.0.0 so is it safe to assume this will be fixed by the time 5.0.0 rolls out? Thanks so much. |
We still need to make the fix, but that's the plan. |
Closed via #25693 |
Uh oh!
There was an error while loading. Please reload this page.
Describe the bug
Calling Abort() in a hub leads to the client's connection status being set to Reconnecting, but only sometimes is a reconnection attempt made. Client's Closed callback is not invoked when this happens. Stopping the connection on the client, while in this state, throws an exception (this part is correct I guess).
Expected behaviour:
When Abort() is called in a hub on server:
Client's Closed callback should get invoked, and client's status should be set to Disconnected. Client should not try to reconnect. It is problematic that it ends up in a Reconnecting state and sometimes tries to reconnect, while completely skipping the closed callback.
To Reproduce
In server's hub, call the following. (Please note that I am actually calling Abort() from outside the hub, by storing the context of the hub in a ConcurrentDictionary in a singleton service as per #5333, until there is a real way to disconnect clients outside the hub. I would assume the bug is exposed even when just calling Abort() inside a hub such as:).
On client:
Further technical details
ASP.NET Core version:
3.1.2
Include the output of
dotnet --info
:.NET Core SDK (reflecting any global.json):
Version: 3.1.200
Commit: c5123d973b
Runtime Environment:
OS Name: Mac OS X
OS Version: 10.15
OS Platform: Darwin
RID: osx.10.15-x64
Base Path: /usr/local/share/dotnet/sdk/3.1.200/
Host (useful for support):
Version: 3.1.2
Commit: 916b5cba26
.NET Core SDKs installed:
3.1.200 [/usr/local/share/dotnet/sdk]
.NET Core runtimes installed:
Microsoft.AspNetCore.App 3.1.2 [/usr/local/share/dotnet/shared/Microsoft.AspNetCore.App]
Microsoft.NETCore.App 2.1.16 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 2.1.17 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
Microsoft.NETCore.App 3.1.2 [/usr/local/share/dotnet/shared/Microsoft.NETCore.App]
VS For Mac 8.6 Preview (build 4387)
The text was updated successfully, but these errors were encountered: