Skip to content

Support using client in repl running tasks without rabbit #1704

Closed

Description

@abbiemery

If you try and use the client in a repl without stomp configured it errors with a stack trace showing it can't connect to the message bus. This is an unhelpful wall of text to be user facing.

>>> bc.plans.count(detectors=[bc.devices.det])
# 2026-10-20 10:00:18,596 INFO blueapi.client.plan_cache plan_cache.py:112 -- Building args for [detectors,num,delay,metadata], using () and {'detectors': [Device(det)]}

# 2026-10-20 10:00:18,605 INFO root messaging.py:366 -- Stomp client connecting...

# 2026-10-20 10:00:18,605 WARNING stomp.py transport.py:893 -- could not connect to host localhost, port 61613: [Errno 111] Connection refused

# 2026-10-20 10:00:18,807 WARNING stomp.py transport.py:893 -- could not connect to host localhost, port 61613: [Errno 111] Connection refused

# 2026-10-20 10:00:19,009 WARNING stomp.py transport.py:893 -- could not connect to host localhost, port 61613: [Errno 111] Connection refused

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/abi/projects/blueapi/src/blueapi/client/plan_cache.py", line 82, in __call__
    match self._client.run_task(req):
          ~~~~~~~~~~~~~~~~~~~~~^^^^^
  File "/home/abi/projects/blueapi/.venv/lib/python3.14/site-packages/observability_utils/tracing/decorators.py", line 151, in wrapper
    return func(*args, **kwargs)
  File "/home/abi/projects/blueapi/src/blueapi/client/client.py", line 400, in run_task
    with self._events:
         ^^^^^^^^^^^^
  File "/home/abi/projects/blueapi/src/blueapi/client/event_bus.py", line 27, in __enter__
    self.app.connect()
    ~~~~~~~~~~~~~~~~^^
  File "/home/abi/projects/blueapi/.venv/lib/python3.14/site-packages/bluesky_stomp/messaging.py", line 368, in connect
    self._connect_to_broker()
    ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/abi/projects/blueapi/.venv/lib/python3.14/site-packages/bluesky_stomp/messaging.py", line 383, in _connect_to_broker
    self._conn.connect(wait=True)  # type: ignore
    ~~~~~~~~~~~~~~~~~~^^^^^^^^^^^
  File "/home/abi/projects/blueapi/.venv/lib/python3.14/site-packages/stomp/connect.py", line 151, in connect
    self.transport.start()
    ~~~~~~~~~~~~~~~~~~~~^^
  File "/home/abi/projects/blueapi/.venv/lib/python3.14/site-packages/stomp/transport.py", line 113, in start
    self.attempt_connection()
    ~~~~~~~~~~~~~~~~~~~~~~~^^
  File "/home/abi/projects/blueapi/.venv/lib/python3.14/site-packages/stomp/transport.py", line 910, in attempt_connection
    raise exception.ConnectFailedException()
stomp.exception.ConnectFailedException

>>>

Acceptance Criteria

  • Preferably:
    -- The fg running option is changed to a websocket by default, removing the message bus from this loop
    -- If there are connection errors these are nicely wrapped for the user
  • Alternatively if if bus really wants to be kept for this:
    -- The client supports a background running option, like the --bg flag on the cli
    -- If you do try and run a plan in the fg without the bus you get a more helpful error

Activity

  1. tpoliaw commented on Oct 20, 2026

    @tpoliaw
    Contributor

    #1646 enables websockets if stomp config isn't available

  2. abbiemery commented on Oct 20, 2026

    @abbiemery
    ContributorAuthor

    Certainly gets us a good chunk of the way there and i'd accept it as a solution to this issue. I would like to move to not using the mb for this at all as it is redundant with the ws.

  3. abbiemery commented on Oct 23, 2026

    @abbiemery
    ContributorAuthor

    Closed by #1646

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    c: clientRelates to client code

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions