Tutorials SignalR & Real-Time .NET Applications
Configuring the Connection: Transports and Retries
On this page
Connection Resiliency
In the real world, connections drop. A senior architect designs for failure by configuring robust retry and transport policies.
1. Automatic Reconnect
On the client side, use .WithAutomaticReconnect(). This tells the SignalR client to try and resume the connection if it drops. You can even pass a custom array of retry intervals (e.g., 0, 2, 10, 30 seconds) to implement an **Exponential Backoff** strategy.
2. Transport Constraints
Sometimes you want to force a specific transport. HttpTransportType.WebSockets ensures your app only works if high-speed duplex is available. This is useful for high-frequency gaming or trading apps where the latency of Long Polling is unacceptable.
3. Architect Insight
Q: "How do I handle 'Dead' connections?"
Architect Answer: "Configure the **ClientTimeoutInterval** and **KeepAliveInterval**. These settings control how often the server and client send 'heartbeat' packets. If a heartbeat is missed, the connection is considered dead, and you can trigger your UI's 'Reconnect' logic."