[Python] SignalR "Hub is not running you cand send messages" when subscribing to account with...

Discussão em 'Python' iniciado por Stack, Maio 16, 2025.

  1. Stack

    Stack Membro Participativo

    I'm working on integrating a real-time trading data feed using SignalR and the signalrcore Python client. I can connect to the hub successfully, and the account discovery API works fine. However, when I try to subscribe to an account via hub.send("SubscribeAccount", [account_id]), I consistently get this error:

    ERROR - Error subscribing to account (attempt 1): Hub is not running you cand send messages

    Console Output:


    INFO - Bearer token loaded from config manager
    INFO - Attempting to connect (attempt 1/3)
    INFO - Starting connection...
    INFO - Connection opened
    INFO - Close message received from server
    INFO - Connection established
    INFO - Connection established successfully
    INFO - Searching for accounts...
    INFO - Found 1 accounts
    INFO - Account found: S1MAY1613963393 (ID: 7873648)
    INFO - Attempting to subscribe to account 7873648 (attempt 1)
    ERROR - Error subscribing to account (attempt 1): Hub is not running you cand send messages
    ...

    My Environment:

    • Python 3.10
    • signalrcore 0.10.1
    • Server URL: wss://rtc.topstepx.com/hubs/user (with bearer token via Authorization header)
    What I’ve Tried:

    • Adding a delay before sending the subscription request
    • Confirming that hub._connected is True
    • Confirmed that the server returns a valid account in /api/Account/search
    • Reconnecting manually before subscription attempt
    • Subscribing immediately after on_open and after a short sleep
    Relevant Code Snippet:


    self._connection = HubConnectionBuilder()\
    .with_url(
    self.USER_HUB,
    options={
    "access_token_factory": lambda: self._bearer_token,
    "skip_negotiation": True,
    "transport": "websockets"
    })\
    .build()

    self._connection.on_open(self._on_open)
    self._connection.on_close(self._on_close)
    self._connection.on_error(self._on_error)

    self._connection.start()
    await asyncio.wait_for(self._connection_ready.wait(), timeout=5)


    await hub.subscribe_account(account_id)


    # Inside `subscribe_account`
    self._connection.send("SubscribeAccount", [account_id])

    Question:


    What does the error "Hub is not running you cand send messages" actually mean? Is this a server-side issue or something I’m doing wrong in the SignalR client setup?

    Any ideas on how to debug or resolve this would be appreciated.

    Continue reading...

Compartilhe esta Página