Skip to main content

ZeroMQ

ZeroMQ is MAGPIE’s core direct transport for Python and C++. It needs no broker and works well on localhost, inside one process, or across a controlled network.

Endpoints​

EndpointUse
tcp://*:5555Bind on all interfaces
tcp://127.0.0.1:5555Connect on the same host
tcp://192.168.1.20:5555Connect over a LAN
inproc://pipelineCommunicate within one process

One side binds and the other connects. In Python readers, set bind=False when connecting. Do not expose an unauthenticated bind endpoint to an untrusted network.

Streaming​

from luxai.magpie.transport import ZmqStreamWriter, ZmqStreamReader

writer = ZmqStreamWriter("tcp://*:5555")
reader = ZmqStreamReader("tcp://127.0.0.1:5555", topic=["robot/"], bind=False)

writer.write({"state": "ready"}, topic="robot/status")
value, topic = reader.read(timeout=2.0)

RPC​

Use ZMQRpcRequester/ZMQRpcResponder in Python and ZmqRpcRequester/ZmqRpcResponder in C++. The responder normally binds; requesters connect.

server = ZMQRpcResponder("tcp://*:5556")
client = ZMQRpcRequester("tcp://127.0.0.1:5556")

Deployment notes​

  • Prefer fixed ports and explicit firewall rules.
  • Use DNS names or discovery instead of embedding changing IP addresses.
  • A bind address of * listens on every network interface; use it intentionally.
  • ZeroMQ is not a replacement for authentication or encryption. Place it on a trusted network or add an appropriate security layer.
  • For cloud-to-robot communication behind NAT, MQTT or WebRTC signaling is usually easier operationally.

Browse the runnable Python ZeroMQ examples or C++ ZeroMQ examples.