Configs2026年9月12日·1 分钟阅读

SignalR — Real-Time Web Communication for .NET

SignalR is a library for ASP.NET that simplifies adding real-time web functionality to applications. It enables server-side code to push content to connected clients instantly using WebSockets with automatic fallback.

Agent 就绪

Agent 可直接安装

这个资产可安装;Agent 先选择当前运行时、检查安装计划,再运行匹配命令。

Native · 98/100策略:允许
Agent 入口
任意 MCP/CLI Agent
类型
Skill
安装
Single
信任
信任等级:Established
入口
SignalR Real-Time Library
直接安装命令
npx -y tokrepo@latest install d80700d1-ae4a-11f1-9bc6-00163e2b0d79 --target codex

先 dry-run 确认安装计划,再运行此命令。

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.

Sources

讨论

登录后参与讨论。
还没有评论,来写第一条吧。

相关资产