dotnet / dotnet/aspnetcore

[SignalR] Add an option to enable client side ping check instead of only relying on client side PingMessage

Open
#23,794 8 comments 0 reactions 1 assignee Claimed by @BrennanConroy View on GitHub
affected-few area-signalr enhancement severity-minor
Dominant language
C#
Stars
38.4k
Forks
10.9k
Avg merge
2d 6h
Merged PRs (30d)
290

Description

### Is your feature request related to a problem? Please describe.
The issue is SignalR server-side relies on the first `PingMessage` to enable the client-side ping check.
https://github.com/dotnet/aspnetcore/blob/2ad8121efbdddd46920918bddb9ee67e1c4144a9/src/SignalR/server/Core/src/Internal/DefaultHubDispatcher.cs#L180

However, if the client-side sends out messages constantly and **more frequently** than keep alive, the client never has any chance to send out `PingMessage`, and as a result the server-side ping check never invokes.

https://github.com/dotnet/aspnetcore/blob/d5cf36acc71fe576541bbb8d694a88815c22c800/src/SignalR/clients/ts/signalr/src/HubConnection.ts#L344

And this can cause the issue that when using SSE to connect to the service, although client fails to send to the server when JWT token expiration(401), the connection never closes, like described here https://github.com/Azure/azure-signalr/issues/943

### Describe the solution you'd like
Provide an option to **explicitly enable** the ping check through `SignalROptions` can solve the issue.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.