Skip to content
Back to skills

Signalr

ASecurity

ASP.NET Core SignalR covering .NET 8, 9, and 10. Deep expertise in hubs, transport negotiation, groups, streaming, authentication, Azure SignalR Service, Redis backplane, MessagePack, and scaling patterns. Use for \"SignalR\", \"hub\", \"HubContext\", \"SignalR group\", \"SignalR streaming\", \"Azure SignalR Service\", \"SignalR backplane\", \"SignalR Redis\", \"SignalR authentication\", \"SignalR reconnect\", \"MessagePack\", \"SignalR scale-out\", \"strongly typed hub\", \"IHubContext\", \"...

  • 4 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added September 24, 2026
developmentjavascriptgojavac#azureapidatabasebackendsecurityperformance

Works with

  • cli
  • api

Security analysis

A100/100

Pro scans all 4 files and shows the line behind each finding

Scanned September 24, 2026

npx -y skills add chrishuffman5/domain-expert --skill signalr --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Signalr?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Signalr
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/chrishuffman5-signalr/badge)](https://www.skillsdirectory.com/skills/chrishuffman5-signalr)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: signalr
description: "ASP.NET Core SignalR covering .NET 8, 9, and 10. Deep expertise in hubs, transport negotiation, groups, streaming, authentication, Azure SignalR Service, Redis backplane, MessagePack, and scaling patterns. Use for \"SignalR\", \"hub\", \"HubContext\", \"SignalR group\", \"SignalR streaming\", \"Azure SignalR Service\", \"SignalR backplane\", \"SignalR Redis\", \"SignalR authentication\", \"SignalR reconnect\", \"MessagePack\", \"SignalR scale-out\", \"strongly typed hub\", \"IHubContext\", \"SignalR .NET\", \"Hub filter\". Do NOT use for general ASP.NET Core framework questions unrelated to real-time hubs (middleware, minimal APIs, EF Core) — use the `aspnet-core` skill in the `backend` plugin for that."
license: MIT
---

# SignalR (.NET 8-10)

This skill covers ASP.NET Core SignalR, Microsoft's real-time communication library for .NET. Covers .NET 8, 9, and 10 (preview). It has deep knowledge of:

- Hub model: methods, strongly-typed hubs, client targeting, lifecycle
- Transport negotiation: WebSocket > SSE > Long Polling
- Groups, user targeting, and connection management
- Streaming: `IAsyncEnumerable<T>`, `ChannelReader<T>` (server and client)
- Authentication: JWT, cookies, custom user ID providers
- Scale-out: Redis backplane, Azure SignalR Service
- Hub protocols: JSON (default), MessagePack (binary)
- Hub filters (`IHubFilter`) for cross-cutting concerns
- `IHubContext<T>` for sending messages from outside hubs

## How to Approach Tasks

1. **Classify** the request:
   - **Architecture / hub design** -- Load `references/architecture.md` for hub model, transports, protocols, lifecycle, streaming
   - **Performance / scaling** -- Load `references/best-practices.md` for Azure SignalR Service, Redis backplane, reconnection, security
   - **Troubleshooting** -- Load `references/diagnostics.md` for connection failures, transport issues, auth problems, scaling issues
   - **Cross-technology comparison** -- Read the `overview` skill for SignalR vs Socket.IO, WebSocket, SSE

2. **Gather context** -- .NET version, transport in use, scaling approach (single server vs Azure SignalR Service vs Redis), authentication method

3. **Analyze** -- Apply SignalR-specific reasoning: hub lifecycle (transient), group persistence, transport fallback behavior, backplane latency.

4. **Recommend** -- Provide C# code, JavaScript client code, and Azure configuration.

## Core Architecture

### Hub Model

Hubs are the central abstraction. Server defines methods callable by clients and vice versa. Hubs are **transient** -- do NOT store state in hub properties.

```csharp
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddSignalR();
var app = builder.Build();
app.MapHub<ChatHub>("/chathub");
```

### Transport Negotiation

Priority: WebSocket (preferred) > SSE > Long Polling. Skip negotiation for performance:
```csharp
options.SkipNegotiation = true;
options.Transports = HttpTransportType.WebSockets;
```

### Client Targeting

`Clients.All`, `Clients.Caller`, `Clients.Others`, `Clients.Client(id)`, `Clients.Group(name)`, `Clients.User(userId)`, `Clients.OthersInGroup(name)`.

### Hub Protocols

JSON (built-in, default) and MessagePack (~30-40% smaller payloads, faster parsing). Add MessagePack: `builder.Services.AddSignalR().AddMessagePackProtocol()`.

### IHubContext for External Messages

```csharp
public class NotificationService(IHubContext<ChatHub> hubContext) : BackgroundService {
    protected override async Task ExecuteAsync(CancellationToken ct) {
        await hubContext.Clients.All.SendAsync("Notification", "Heartbeat", ct);
    }
}
```

## Anti-Patterns

1. **Storing state in hub properties** -- Hubs are transient. Each method call creates a new instance. Use external state (Redis, database).
2. **Not re-joining groups after reconnect** -- Groups are cleaned up on disconnect. Persist group membership and re-join in `OnConnectedAsync`.
3. **Calling `RemoveFromGroupAsync` in `OnDisconnectedAsync`** -- Groups auto-cleanup. No need to remove.
4. **Enabling `DetailedErrors` in production** -- Exposes internal error details to clients. Only use in development.
5. **Ignoring token expiry on long-lived connections** -- WebSocket connections remain authenticated after token expires. Use `CloseOnAuthenticationExpiration: true` or validate per-message.
6. **Not using `IHubContext` from outside hubs** -- Never instantiate a hub directly. Use DI-injected `IHubContext<T>`.
7. **Blocking hub methods** -- Hub methods block the connection pipeline. Use `async/await` and return quickly.
8. **Strongly typed hubs with Native AOT** -- `Hub<T>` is not compatible with Native AOT (.NET 9+).

## Reference Files

- `references/architecture.md` -- Hub model, transports, protocols, lifecycle, streaming, groups, strongly-typed hubs, hub filters, client results
- `references/best-practices.md` -- Authentication (JWT, cookies), Azure SignalR Service, Redis backplane, reconnection, MessagePack, performance, security
- `references/diagnostics.md` -- Connection failures, transport negotiation issues, auth problems, scaling issues, streaming errors, group management

## Cross-References

- `overview` skill -- SignalR vs Socket.IO, WebSocket, SSE comparisons
- `aspnet-core` skill (in the `backend` plugin) -- ASP.NET Core framework context

Files in this skill

  • SKILL.md5.2 KB
  • references/architecture.md5.9 KB
  • references/best-practices.md6.3 KB
  • references/diagnostics.md6.3 KB

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

Comments

Loading comments…