Introducing a new way to review your PRs.

Read the announcement

floci-io / floci-az

Light, fluffy, and always free - Local Azure Emulator

View on GitHub

27 documents · Updated Nov 23, 2026

docs / azure-signalr-service

Azure SignalR Service

Azure SignalR Service gives local ASP.NET Core applications a real-time relay for hub connections. The emulator covers the Default mode data path over WebSockets, while its ARM management path reports that SignalR REST management is not implemented. It validates SDK-issued access tokens, issues short-lived connection tokens during negotiation, carries hub messages between clients and application servers, and keeps connection state in memory. This page is a child of Azure platform services; see Azure Policy service, Core routing and auth for shared request rules, Azure identity and security for token-related behavior, and Compatibility tests for the wider validation model.

Service boundary

ARM management boundary

The ARM boundary exists so the emulator can identify SignalR service requests and return a clear result. SignalR resource management is not available through this path, so applications must use the local data-plane endpoint and its configured access key for real-time work.

SignalR endpoints can use the local root or an account-style host. A -signalr account prefix and a .service.signalr.net host select the account that owns the hub. The hub name is part of the data-plane request and is matched without regard to letter case.

References: src/…/SignalRHandler.java• L20-37 src/…/SignalRWebSockets.java• L44-61

Data-plane relay

The data plane connects two kinds of actors: application servers that host hubs and clients that call those hubs. The service keeps the relay inside the emulator process, so a local run does not need a sidecar or a persistent connection store.

The application server connection is the source of hub execution. The service forwards client data to the selected server and forwards server results to the matching clients. A client cannot complete negotiation until a ready server accepts clients for the same account and hub.

References: src/…/SignalRConnections.java• L19-24 src/…/SignalRConnections.java• L89-103

Connection negotiation

Access-token use

SignalR access tokens authorize both the negotiate request and the later WebSocket request. The emulator does not mint these service access tokens. The SDK or application supplies a signed token, and the emulator checks its HS256 signature, audience, and time limits with the configured access key.

The token can arrive as a bearer header or as the access_token query value. Its claims provide the user identity used for user-targeted messages. They can also request preferred or required application-server stickiness. The emulator passes the validated claims to the selected application server so that the server and client share the same connection identity.

References: src/…/SignalRTokens.java• L16-25 src/…/SignalRTokens.java• L28-56 src/…/SignalRWebSockets.java• L62-71

Negotiation response

The client sends a POST request to the hub's negotiate endpoint after the SDK has connected an application server. The service returns a connection ID and a separate short-lived connection token. The connection token is an in-memory reference to the pending negotiation. It links the next WebSocket request to the negotiated client and expires after 30 seconds.

Only WebSockets are advertised. The response lists text and binary transfer formats because the selected hub protocol can use either form. The service rejects negotiation when no ready application server can serve the hub.

The main negotiation and connection path is shown below.

sequenceDiagram
    participant A as Application server
    participant S as SignalR service
    participant C as Client
    A->>S: Open server WebSocket
    S-->>A: Service handshake complete
    C->>S: POST client negotiate
    S-->>C: Connection ID and short-lived connection token
    C->>S: WebSocket upgrade with token
    S->>A: Open client connection
    C->>S: Hub handshake and invocation
    S->>A: Relay hub data
    A->>S: Hub result or broadcast
    S-->>C: Relay hub data

References: src/…/SignalRWebSockets.java• L72-99 src/…/SignalRConnections.java• L89-107

WebSocket handling

Server WebSockets

An application server opens a WebSocket on the server route for a hub. It then completes the Azure SignalR service handshake. A ready server may accept clients unless it reports that it is not accepting new clients.

The service uses the server's hub and server identity to choose client ownership. It also sends periodic service pings so an otherwise quiet connection remains active and can answer service status or server-list requests.

References: src/…/SignalRConnections.java• L27-45 src/…/SignalRConnections.java• L72-91 src/…/SignalRConnections.java• L194-215

Client WebSockets

After negotiation, the client opens a WebSocket with its connection token. The service checks that the token belongs to the same hub and user as the pending negotiation before it admits the connection. The token is consumed during this check, so the pending connection cannot be used for a second upgrade.

The service assigns the client to an available server. Preferred stickiness uses the requested server when it is available. Required stickiness fails the assignment when that server is not available. Without a stickiness request, the service spreads clients across available servers.

References: src/…/SignalRWebSockets.java• L81-99 src/…/SignalRConnections.java• L93-108

Hub protocol messages

Protocol selection

The client sends a SignalR hub handshake as its first data. The handshake names either the JSON or MessagePack hub protocol. The service records that choice for the client, sends the choice to the owning application server as part of the client-open message, and then relays later hub data in the matching format.

This hub protocol is separate from the Azure service protocol. The hub protocol carries application messages between a client and its hub. The service protocol carries framed control and data messages between the emulator and an application server.

References: src/…/SignalRConnections.java• L110-135 compatibility-tests/…/SignalRCompatibilityTests.cs• L21-42 compatibility-tests/…/SignalRCompatibilityTests.cs• L79-90

Service protocol

The application-server link uses binary MessagePack arrays with a base-128 length prefix. The protocol supports server readiness, client data, close requests, keep-alive messages, group changes, and fan-out targets.

The service reads complete frames even when a WebSocket delivers data in several chunks. It rejects malformed frames and frames larger than 1 MiB. Unsupported service message types close the server link instead of pretending that the operation succeeded.

References: src/…/SignalRProtocol.java• L18-62 src/…/SignalRProtocol.java• L64-101 src/…/SignalRConnections.java• L137-173

Message targets

Application servers can send hub data to one connection, one user, a group, several users, or all clients with connection and user exclusions. Group membership belongs to the live client connection and is shared across application servers for the same account and hub.

The service applies the target to clients that use the same hub scope. It then sends each client the payload in that client's selected protocol. This lets JSON and MessagePack clients use one hub at the same time.

References: src/…/SignalRConnections.java• L150-191 compatibility-tests/…/SignalRCompatibilityTests.cs• L43-60

Local connection lifecycle

Connection ownership

Each live client has one owning application server. The service uses this relationship for client-to-server calls, server-to-client results, group changes, and cleanup. User identity and group membership stay with the live connection rather than with a persistent account record.

When a client closes, the service removes it and informs its application server. When an application server closes, the service removes the server and closes every client assigned to it. Clients must connect again after that event.

References: src/…/SignalRConnections.java• L47-70 src/…/SignalRConnections.java• L217-231

Timeouts and back pressure

The service removes expired pending negotiations and checks open connections on a short timer. An incomplete server or client handshake times out. A client or server that cannot keep up is closed with a temporary failure code.

These rules keep local state bounded and make a failed application-server link visible to clients. They also mean that a restart or process shutdown removes all SignalR connections and group membership.

References: src/…/SignalRWebSockets.java• L37-43 src/…/SignalRConnections.java• L41-43 src/…/SignalRConnections.java• L64-68 src/…/SignalRConnections.java• L208-231

Compatibility scope

The compatibility path uses real ASP.NET Core hub hosts with the Azure SignalR SDK. It checks two application servers, separate application names, JSON and MessagePack clients, server selection, groups, users, broadcasts, reconnects, and keep-alive behavior.

The supported scope is the WebSocket Default mode. Server-Sent Events, long polling, serverless upstreams, REST management, Microsoft Entra authentication, migration, stateful reconnect, and result-returning server-to-client invocations are outside this emulation.

References: compatibility-tests/…/SignalRCompatibilityTests.cs• L14-67 compatibility-tests/…/SignalRCompatibilityTests.cs• L79-111 src/…/SignalRHandler.java• L31-37

Change checklist

When these files or sections are changed, remember to consider these:

  • If the token audience or hub route changes, keep the SDK connection string, token validation, negotiate path, and WebSocket path aligned.
  • If negotiation fields or connection-token lifetime changes, keep the client upgrade lookup and token expiry rules consistent.
  • If a service-protocol message shape changes, update framing, server readiness, routing, and close behavior together.
  • If hub protocol handling changes, preserve the format chosen by each client when the service forwards payloads.
  • If server selection claims change, keep server identity headers, sticky claims, and client ownership rules in sync.
  • If connection cleanup changes, verify that server loss removes assigned clients and that group membership is not left behind.
  • If account or hub isolation changes, check both host-based routing and the in-memory connection key.

Important failure modes

TriggerConsequenceGuard
Client negotiates before a ready application server existsNegotiation returns NoServerConnectionStart the application-server connection before client startup
Access token has a bad signature, audience, or lifetimeNegotiate or WebSocket admission returns unauthorizedUse the configured access key and the exact local SignalR audience
Connection token is reused, expired, or tied to another hub or userThe WebSocket upgrade returns ConnectionNotFoundComplete the upgrade within 30 seconds with the same hub and user
Required sticky server is unavailableThe client WebSocket closes without an ownerKeep the named application server ready or use preferred stickiness
Application server WebSocket closesAll clients owned by that server disconnectReconnect the application server and let clients reconnect
Service protocol frame is malformed, unsupported, or over 1 MiBThe server link closesUse version 1 binary service frames within the size limit
Client sends an unsupported hub protocolThe client WebSocket closes during the hub handshakeUse JSON or MessagePack

Key files

FileWhy to read it
src/…/SignalRHandler.javaShows the ARM boundary and SignalR route registration
src/…/SignalRWebSockets.javaShows negotiation, token admission, connection-token issuance, endpoint selection, and WebSocket upgrades
src/…/SignalRTokens.javaShows access-token checks and identity and stickiness claims
src/…/SignalRConnections.javaShows server ownership, client routing, groups, fan-out, pings, and cleanup
src/…/SignalRProtocol.javaShows the framed MessagePack service link between the emulator and application servers
compatibility-tests/…/SignalRCompatibilityTests.csShows the end-to-end Default mode behavior expected from real ASP.NET Core hosts and clients
src/…/EmulatorConfig.javaShows the SignalR enable switch and shared access-key setting