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
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.206s · 19.5MB
glibcpy 3.10–3.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.")
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'signalrcore'
The `signalrcore` package has not been installed in the active Python environment.
fixpip install signalrcore
TypeError: __init__() missing 1 required positional argument: 'hub_url'
The `HubConnectionBuilder` constructor was called without providing the essential `hub_url` argument.
fixhub_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.
fixhub_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.
fixEnsure 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.
fixVerify 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.