Introduction
aiosignalr is a high-performance, asyncio-native implementation of the SignalR hub protocol for Python. It provides both a client and a server in one package, covering the WebSocket, Server-Sent Events and Long Polling transports with JSON and MessagePack message encoding.
SignalR is the real-time framework behind many .NET applications. aiosignalr
lets Python services speak the same wire protocol, so they can interoperate
with ASP.NET Core servers and clients, browsers using
@microsoft/signalr, and
any other SignalR implementation.
Why aiosignalr?
- Pure
asyncio— no blocking calls, designed for high-concurrency event-driven Python services. - Full-duplex client and server over WebSocket, with transport fallback: the client negotiates transports in server-declared order (WebSocket → Server-Sent Events → Long Polling).
- Both hub protocols: the JSON protocol (
0x1E-delimited) and the MessagePack protocol (VarInt length-prefixed binary). - Complete client features:
invoke,stream, fire-and-forgetsend, client-to-server upload streams, server method handlers, keep-alive pings, server-timeout detection, and automatic reconnect with a pluggable retry policy. - Complete server features: hub methods (single result and streaming), groups, broadcast to all / connection / group / user, client results, invocation cancellation, upload-stream parameters, negotiation and handshake protocol selection.
- Stateful reconnect: the ASP.NET Core
useAck/Ack/Sequencebuffering protocol on both ends, preserving in-flight messages across a transport drop without loss or duplication. - Flexible hosting: a standalone
asyncioserver or an ASGI application you can mount in uvicorn / FastAPI. - Tested against the reference implementation: an interop test-suite runs
aiosignalr against a real ASP.NET Core SignalR server and a real
Microsoft.AspNetCore.SignalR.Clientagainst aiosignalr.
Feature matrix
| Area | WebSocket | Server-Sent Events | Long Polling |
|---|---|---|---|
| Server → client | ✔ | ✔ | ✔ |
| Client → server | ✔ (duplex) | HTTP POST | HTTP POST |
| JSON protocol | ✔ | ✔ | ✔ |
| MessagePack protocol | ✔ | ✘ | ✔ |
| Stateful reconnect | ✔ | ✘ | ✘ |
Compatibility
aiosignalr speaks the standard SignalR protocol, so it interoperates with:
- ASP.NET Core servers (
MapHub) and clients (HubConnectionBuilder), including stateful reconnect. @microsoft/signalrJavaScript clients.- Any SignalR implementation that follows the Transport Protocols and Hub Protocol specifications.
Requirements
- Python 3.11+.
aiohttp,websocketsandmsgpack(installed automatically).