Skip to content

.NET SignalR client getting stuck sending messages #41150

@navidmatin

Description

@navidmatin

Is there an existing issue for this?

  • I have searched the existing issues

Describe the bug

Since updating to v5.0.10 or newer of the .NET SignalR client (from v3.1.5) we have noticed that some of the clients get into a state that causes connections to lock up. This causes the client to go offline without closing the connection or triggering our client reconnect logic.
The initial observation was that the SendAsync (which is an extension method that calls SendCoreAsync) freezes and causes the connection to timeout and the client to get disconnected. After adding a cancellation token with a timeout of 10 seconds, we managed to prevent the client from getting locked up but we are still seeing an issue that the connection state is Connected but it cannot send messages to our SignalRHub.
Additionally, as part of the efforts to fix this, I added a call to StopAsync to stop the connection and restart it. However, StopAsync also freezes when the client is in this state. After further research, I realized that StopAsync does not respect the cancellation token so had to remove the call to this method.

Expected Behavior

  • SignalR client should be able to send messages to the server if it is connected to the SignalR Hub.
  • (in my opinion) the SignalR client should have a default timeout value (similar to HttpClient) to prevent lock-up in case of failure to send messages to the server.
  • Cancellation token that gets passed into StopAsync should not get ignored.

Steps To Reproduce

Unfortunately, I have not been able to reproduce this locally, but I have observed this reliably in the production environment.

Exceptions (if any)

No response

.NET Version

Client .Net 4.6.1 | Server .NET 6.0

Anything else?

We are using 10 US-West and 10 US-East instances of Azure SignalR Service and we have observed this behavior on ServerSentEvent and Websocket transports.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions