Skip to content

SignalR C++ crashes after connection loss and does not reconnect #28447

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

Closed
notpidgey opened this issue Dec 5, 2020 · 4 comments
Closed

SignalR C++ crashes after connection loss and does not reconnect #28447

notpidgey opened this issue Dec 5, 2020 · 4 comments
Labels
area-signalr Includes: SignalR clients and servers ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. Status: Resolved

Comments

@notpidgey
Copy link

Describe the bug

While being connected to an ASP.net Core SignalR Hub, if the users internet experiences any instabilities, the C++ client crashes and stops the connection.

To Reproduce

  1. Use the sample project provided under the SignalR-Client-Cpp repository SignalR-Client-Cpp Sample
  2. Connect to a hub hosted on a server that is not your local machine
  3. Disconnect from your VPN or disable WiFi

Exceptions

The following is printed out to the console by the logger once step 3 is complete.
[error ] [websocket transport] error receiving response from websocket: Underlying Transport Error
[state change] connected -> disconnected
[info ] Stop ignored because the connection is already disconnected. connection stopped successfully
[error ] Connection closed with error: Underlying Transport Error
[info ] acquired lock in shutdown()

Further technical details

  • ASP.NET Core 5.0

Disconnecting from a VPN or WiFi is the most consistent way to reproduce this issue but this can occur from minor internet outages.
This issue is very troubling as it makes the client very unstable to use without any attempt to reconnect. There have been many instances where this has caused my application to crash because it suddenly terminates the connection and does not reconnect to the hub.

@notpidgey
Copy link
Author

I discovered a new issue with this situation. When turning off your internet while being connected to a hub via the C++ client, OnDisconnect is called after 15 minutes or more around 980k milliseconds since the client had disconnected.

@mkArtakMSFT mkArtakMSFT added the area-signalr Includes: SignalR clients and servers label Dec 7, 2020
@BrennanConroy
Copy link
Member

the C++ client crashes and stops the connection

Does it actually crash? Or does it only close the connection?

Reconnect isn't supported in the C++ client currently. You can implement it yourself though by detecting connection close and calling start again (with some sort of retry policy).

When turning off your internet while being connected to a hub via the C++ client, OnDisconnect is called after 15 minutes or more around 980k milliseconds since the client had disconnected.

This is expected until ping support is added to the client. #8721

@BrennanConroy BrennanConroy added the Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. label Dec 7, 2020
@notpidgey
Copy link
Author

Does it actually crash? Or does it only close the connection?

My apologies I worded that extremely poorly, the application exits successfully and closes.

I will try to implement the connection retry client side. Unfortunately the 15 minute disconnect is a pretty big issue as I am unable to keep track of clients who are actually connected.
Is there some kind of solution to this, the only thing I can imagine is adding a ping method on the hub, requiring the client to call it within a specific time period or else they get disconnected via a context abort. Would there be a cleaner way of doing this?

@ghost ghost added Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. and removed Needs: Author Feedback The author of this issue needs to respond in order for us to continue investigating this issue. labels Dec 7, 2020
@BrennanConroy
Copy link
Member

Is there some kind of solution to this, the only thing I can imagine is adding a ping method on the hub, requiring the client to call it within a specific time period or else they get disconnected via a context abort. Would there be a cleaner way of doing this?

That's effectively what we would do, except that it's internal (and a bit more efficient).

@BrennanConroy BrennanConroy added ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. and removed Needs: Attention 👋 This issue needs the attention of a contributor, typically because the OP has provided an update. labels Dec 7, 2020
@ghost ghost added the Status: Resolved label Dec 7, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jan 7, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
area-signalr Includes: SignalR clients and servers ✔️ Resolution: Answered Resolved because the question asked by the original author has been answered. Status: Resolved
Projects
None yet
Development

No branches or pull requests

3 participants