[SignalR] Stateful reconnect
See original GitHub issueAllows the server to retain the send buffer while the client is reconnecting and preserve connection state (Context.Items, connection ID, etc.).
Thoughts:
- Would need to be opt-in and supported by both client and server. Because client needs to change to try to reconnect with the same connection ID as its previous connection.
- Need an option to configure how long to keep the connection state on the server
- Skip negotiate doesn’t play well in a multi-server environment when sticky-sessions aren’t enabled
- How does it work with Azure SignalR Service
- Does the client need a new event to say “doing stateful reconnect”? What’s the interaction with the current automatic reconnect feature?
- If client connects with different auth credentials, do we replace the
User?
Needs work:
- Configurable buffer limit(s), total bytes count and maybe total message count too
- Versioning, probably increment HubProtocol and add “ack protocol”
- Try to push feature fully into SignalR layer, i.e. get new ConnectionContext from lower layer and map onto existing connection
- Replace IReconnectFeature with IExistingConnectionFeature or something, that contains the previous ID on the new ConnectionContext (because client will send old id via query string)
- Need timeout logic in SignalR layer then
- And pause the read loop waiting for a new connection
- Figure out what happens when a seamless reconnect takes too long, do we just kill the connection attempt, or keep it as a new connection (since the ConnectionContext is completely new) and send the new ID back to the client somehow?
- Potentially send a CloseMessage from clients to have a guaranteed way of knowing the connection close is graceful
- If not, finalize IReconnectFeature API
- Fix StopAsync race in WebSocketsTransport (Running task being overwritten), it might be delaying reconnect fallback logic
- Pool buffers in MessageBuffer
- Finalize options for enabling the feature, both client and server side
- And disallowing the feature from server side
- Retry policy for seamless reconnect attempts, separate from current reconnect policies
- Fix many TODOs in current code
Issue Analytics
- State:
- Created 7 months ago
- Reactions:3
- Comments:19 (6 by maintainers)
Top Results From Across the Web
Understanding and Handling Connection Lifetime Events ...
This article provides an overview of the SignalR connection, reconnection, and disconnection events that you can handle, and timeout and ...
Read more >SignalR .Net Client: how to re-establish a connection
To do that, you can call the Start method from your Closed event handler (disconnected event handler on JavaScript clients). You might want...
Read more >SignalR vs. WebSocket: Key differences and which to use
SignalR provides features such as automatic reconnections, fallback transports, or the ability to broadcast messages to all connected clients, ...
Read more >Scaling Out Your Own SignalR Chat Application
SignalR will automatically reconnect when the server comes back up but will not buffer messages. In other words, any message sent while the ......
Read more >WebSocket vs SignalR: An In-Depth Comparison
SignalR handles connection management, reconnection, authentication, authorization, grouping, broadcasting, etc., for you. Simple and easy ...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I wanted to give my feedback and this feature. This feature is amazing and a must have. I’ve been engaging with our VPN team with connection issues to our Blazor application. One of our VPN or firewall is dropping the websocket connection. After testing with this feature turned on the issue isn’t even noticeable. Please ship this with .NET 8.
This capability is too important for Blazor Server, and I hope that in the future, Blazor Server will not cause the entire program to crash due to network reasons.