Registry / azure / signalrcore

signalrcore

JSON →
library1.0.2pypypi✓ verified 24d ago

signalrcore is a full-featured Python client for SignalR Core hubs, offering support for various transports (WebSockets, Server-Sent Events, Long Polling) and encodings (JSON, MessagePack). It's designed to be compatible with Azure SignalR Service and serverless functions, and includes robust automatic and manual reconnection capabilities. The library abstracts away the complexities of SignalR protocol negotiation, transport fallback, and message dispatching, allowing developers to focus on defining event callbacks. Currently at version 1.0.2, it receives active development and maintenance.

pip install signalrcore
INSTALL
IMPORT
SIG · SIGNALRCORE
S
signalrcore
azurepythonv1.0.2
Install
1.8s avg
Import
195ms
Disk
18MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.0.2 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.206s · 19.5MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 0.184s · 20MB
18MB installed
● package 18MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

HubConnectionBuilder
from signalrcore.hub_connection_builder import HubConnectionBuilder
Primary builder for synchronous/blocking connections.
AIOHubConnectionBuilder
from signalrcore.aio.aio_hub_connection_builder import AIOHubConnectionBuilder
Builder for asyncio-compatible connections.

This example demonstrates how to establish a connection to a SignalR hub, set up event handlers for connection status, register a callback for a server-side method, and send messages. It includes basic logging configuration and automatic reconnection, and uses an environment variable for the hub URL for better configurability. Remember to replace `http://localhost:5000/hub` with your actual SignalR hub URL.

import logging import time import os from signalrcore.hub_connection_builder import HubConnectionBuilder # Configure logging for better visibility handler = logging.StreamHandler() handler.setLevel(logging.DEBUG) hub_connection = HubConnectionBuilder() \ .with_url(os.environ.get('SIGNALR_HUB_URL', 'http://localhost:5000/hub')) \ .configure_logging(logging.DEBUG, socket_trace=True, handler_mapping={ "httpx": logging.WARNING, "websocket": logging.WARNING, "urllib3": logging.WARNING }) \ .with_automatic_reconnect({ "type": "interval", "keep_alive_interval": 10, "intervals": [1, 2, 5, 10, 15, 30] # In seconds }) \ .build() hub_connection.on_open(lambda: print("Connection opened.")) hub_connection.on_close(lambda: print("Connection closed.")) hub_connection.on_error(lambda data: print(f"Connection error: {data.error}")) # Define a callback for a specific method on the hub def receive_message(args): print(f"Received message: {args}") hub_connection.on("ReceiveMessage", receive_message) print("Starting connection...") hub_connection.start() print("Connection started.") # Keep the connection alive for some time and send a message try: # Give some time for the connection to establish and possibly auto-reconnect time.sleep(5) if hub_connection.connected: print("Sending message to hub...") hub_connection.send("SendMessage", ["PythonClient", "Hello from Python!"]) print("Message sent. Waiting for 30 seconds to receive messages or keep alive.") time.sleep(30) # Keep connection alive and listen for messages else: print("Connection not established or reconnected. Cannot send message.") except KeyboardInterrupt: pass finally: print("Stopping connection...") hub_connection.stop() print("Connection stopped.")
Debug
Known issues
breakingVersion 1.0.1 and newer of `signalrcore` require Python 3.9 or higher. Additionally, the `msgpack` dependency was updated to `1.1.2`. Users on older Python versions or with conflicting `msgpack` installations may encounter compatibility issues upon upgrading.
fix
Ensure your environment uses Python 3.9+ and update `msgpack` to `1.1.2` or the version specified in `signalrcore`'s `install_requires`.
affects: 1.0.1+
gotchaThe error 'Hub is not running you cant send messages' typically occurs when attempting to send data before the SignalR connection is fully established or after it has unexpectedly closed. The connection might take a few moments to negotiate and connect, especially with automatic reconnection configured.
fix
Always check `hub_connection.connected` before sending messages. Implement appropriate delays or listen for the `on_open` event before initiating message sends. Review logs (configured to DEBUG level) for connection status and re-connection attempts.
affects: All versions
gotchaPrior to version 1.0.2, the client could experience 'fragmented messages error' when receiving large messages over WebSocket or Server-Sent Events transports. This could lead to incomplete message processing or connection instability.
fix
Upgrade to `signalrcore` version 1.0.2 or newer to benefit from the fix for fragmented message handling.
affects: <1.0.2
gotchaSignalR hub method names invoked from the client, as well as user and group identifiers used for targeting specific clients on the server, are case-sensitive. A mismatch in casing between the client invocation and the server-side method or identifier can lead to calls silently failing or messages not being delivered.
fix
Ensure that the casing of method names (e.g., `hub_connection.send("SendMessage", ...)` vs. server's `SendMessage` or `sendMessage`) and user/group IDs matches exactly between your Python client and the SignalR server.
affects: All versions
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'signalrcore'
The `signalrcore` package has not been installed in the active Python environment.
fix
pip install signalrcore
TypeError: __init__() missing 1 required positional argument: 'hub_url'
The `HubConnectionBuilder` constructor was called without providing the essential `hub_url` argument.
fix
hub_connection_builder = HubConnectionBuilder().with_url("http://localhost:5000/myhub")
AttributeError: 'HubConnectionBuilder' object has no attribute 'start'
A method like `start()` is being called on the `HubConnectionBuilder` object itself, instead of on the `HubConnection` object returned by its `build()` method.
fix
hub_connection = HubConnectionBuilder().with_url("http://localhost:5000/myhub").build()
hub_connection.start()
signalrcore.protocol.unsupported_protocol_version: UnsupportedProtocolVersion: "The server returned an unsupported protocol version."
The `signalrcore` client connected to a server using an incompatible SignalR protocol version, most commonly an older ASP.NET SignalR (not Core) server.
fix
Ensure the SignalR server is a .NET Core or ASP.NET 5+ SignalR implementation, as `signalrcore` is designed exclusively for SignalR Core.
ConnectionRefusedError: [Errno 111] Connection refused
The client failed to establish a network connection because the target SignalR server was not running, was inaccessible at the specified address/port, or was blocked by a firewall.
fix
Verify that the SignalR server application is running, listening on the correct URL and port, and check for network connectivity issues or firewall restrictions.
Upgrade
Version history
1.0.2latest on PyPI · released Feb 25, 2026
Audit
Dependencies
pythonrequiredMinimum Python version required.
msgpackrequiredRequired for MessagePack encoding support.
Agent activity
40 hits · last 30 days
node
32
OpenAI (training)
1
Resources
signalrcore — pip install signalrcore · libregistry