Skip to main content

Unified Python client for Microsoft SignalR supporting: - Classic ASP.NET SignalR 2.x - ASP.NET Core SignalR (JSON and MessagePack)

Features: - Thread-based implementation (no gevent dependency) - Optional asyncio support - Comprehensive security features (input validation, JSON limits, SSL warnings) - TLS, proxies, reconnect with backoff, and bearer token authentication - Resource limits and timeout controls

Requirements

Install requirements by running:

pip install -r requirements

Or install from PyPI:

pip install signalr-unified-client

Compatibility

  • Python: 3.8–3.13

  • Servers: - Classic ASP.NET SignalR 2.x: supported (SSE + WebSockets) - ASP.NET Core SignalR: JSON and MessagePack over WebSockets

Usage

Here is sample usage:

from requests import Session
from signalr import Connection

with Session() as session:
    # Create a connection (URL is validated automatically)
    connection = Connection("http://localhost:5000/signalr", session)

    # Configure timeouts and resource limits (optional)
    connection.connection_timeout = 600.0  # 10 minutes
    connection.idle_timeout = 120.0  # 2 minutes
    connection.max_hubs = 10

    # Get chat hub (hub name is validated)
    chat = connection.register_hub('chat')

    # Start a connection
    connection.start()

    # Create new chat message handler
    def print_received_message(data):
        print('received: ', data)

    # Create new chat topic handler
    def print_topic(topic, user):
        print('topic: ', topic, user)

    # Create error handler
    def print_error(error):
        print('error: ', error)

    # Receive new chat messages from the hub (method name is validated)
    chat.client.on('newMessageReceived', print_received_message)

    # Change chat topic
    chat.client.on('topicChanged', print_topic)

    # Process errors
    connection.error += print_error

    # Start connection, optionally can be connection.start()
    with connection:

        # Post new message (method name is validated)
        chat.server.invoke('send', 'Python is here')

        # Change chat topic
        chat.server.invoke('setTopic', 'Welcome python!')

        # Invoke server method that throws error
        chat.server.invoke('requestError')

        # Post another message
        chat.server.invoke('send', 'Bye-bye!')

        # Wait a second before exit
        connection.wait(1)

Security

The library includes comprehensive security features:

  • Input Validation: All user inputs (URLs, hub names, method names, query parameters) are validated

  • JSON Size Limits: Maximum 1MB message size and 32-level nesting depth

  • SSL Security: Automatic warnings for insecure SSL configurations

  • Resource Limits: Connection timeouts, idle timeouts, and message queue limits

  • Header Validation: CRLF injection prevention

  • Security Logging: Events logged to signalr.security logger

See docs/CONFIG.md and docs/USAGE.md for detailed security configuration.

Metadata

Release files for signalr-unified-client 0.0.10

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for signalr-unified-client 0.0.10
File Size Uploaded
signalr_unified_client-0.0.10.tar.gz 25.2 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for signalr-unified-client 0.0.10
File Interpreter ABI Platform
signalr_unified_client-0.0.10-py3-none-any.whl Python 3 none any Details

Total release size: 52.6 kB

Release files / signalr_unified_client-0.0.10.tar.gz

Download URL signalr_unified_client-0.0.10.tar.gz
Size 25.2 kB
Tags Source
SHA-256 checksum
How to use checksums
5df57653ba4127875aaa0fb36f745b55aebc2f7e26ae450b55ea18c72bdba5a1
BLAKE2b-256 checksum
How to use checksums
5d628454a31d455378688e1dd25f4e24fc0431f085b2bc5647aa4a81be131fa4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / signalr_unified_client-0.0.10-py3-none-any.whl

Download URL signalr_unified_client-0.0.10-py3-none-any.whl
Size 27.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
abd9758f51e9156c6c1f528da0dc4acdfdc14555147d80cacd1dce9820449f43
BLAKE2b-256 checksum
How to use checksums
4374ec8970fe2e49fc2c2c941547b5a691d2f8f572aa1eab98909a21d67ee442
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release history Release notifications | RSS feed

This release

0.0.10 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page