Introduction
SignalR is part of ASP.NET Core and provides an abstraction over real-time communication protocols. It handles connection management, grouping, and broadcasting automatically, letting developers focus on application logic rather than low-level transport details.
What SignalR Does
- Manages persistent connections between server and clients with automatic reconnection
- Negotiates the best available transport (WebSockets, Server-Sent Events, Long Polling)
- Supports broadcasting to all clients, specific groups, or individual connections
- Provides strongly typed hub methods callable from both server and client sides
- Scales horizontally with Redis, Azure SignalR Service, or SQL Server backplanes
Architecture Overview
SignalR uses a Hub abstraction that maps RPC-style method calls between server and clients. When a client connects, SignalR negotiates the best transport protocol starting with WebSockets. The Hub dispatches incoming calls to server methods and pushes results back through the connection. For multi-server deployments, a backplane (Redis or Azure SignalR Service) replicates messages across instances so every connected client receives updates regardless of which server it connects to.
Self-Hosting & Configuration
- Add the SignalR NuGet package and call AddSignalR() in your service configuration
- Map hub endpoints using MapHub() in the routing pipeline
- Configure transport options, keep-alive intervals, and buffer sizes as needed
- Deploy with a Redis backplane for horizontal scaling across multiple servers
- Use the Azure SignalR Service for fully managed hosting without infrastructure management
Key Features
- Automatic transport negotiation with WebSocket, SSE, and Long Polling fallback
- Built-in connection lifecycle management with reconnection support
- Group-based messaging for channels, rooms, or topic subscriptions
- Streaming support for server-to-client and client-to-server data flows
- Client SDKs for JavaScript, .NET, Java, and Swift
Comparison with Similar Tools
- Socket.IO — Node.js real-time library; broader language support but no .NET integration
- gRPC streaming — Binary protocol with strict contracts; better for service-to-service, heavier for browsers
- Centrifugo — Language-agnostic real-time server; good standalone option, separate deployment
- Pusher / Ably — Managed real-time services; no self-hosting option, usage-based pricing
- WebSocket API (raw) — Full control but requires manual reconnection, serialization, and routing
FAQ
Q: Does SignalR require WebSocket support? A: No. SignalR automatically falls back to Server-Sent Events or Long Polling when WebSockets are unavailable.
Q: How does SignalR scale across multiple servers? A: Use a backplane such as Redis or Azure SignalR Service to distribute messages across server instances.
Q: Can I use SignalR with non-.NET clients? A: Yes. Official client SDKs exist for JavaScript, Java, and Swift. Community clients cover Python and other languages.
Q: Is SignalR suitable for high-frequency data like stock tickers? A: Yes, especially with the streaming APIs. For very high throughput, consider batching updates to reduce message overhead.