OpenClaw Gateway Architecture Explained
Understand the OpenClaw WebSocket Gateway, clients, nodes, canvas host, pairing, auth, and remote access model.
Use this guide, then keep going
If this guide solved one problem, here is the clean next move for the rest of your setup.
Most operators land on one fix first. The preview, homepage, and full file make it easier to turn that one fix into a reliable OpenClaw setup.
The OpenClaw Gateway is the long-lived process that makes the rest of the system feel coherent. It owns messaging provider connections, exposes a typed WebSocket API, validates frames, emits events, and serves control-plane clients. If you run OpenClaw beyond a demo, the Gateway is the piece you should understand first.
One Gateway, many surfaces
The architecture docs describe a single long-lived Gateway owning messaging surfaces such as WhatsApp via Baileys, Telegram, Slack, Discord, Signal, iMessage, and WebChat. Control-plane clients like the macOS app, CLI, web UI, and automations connect over WebSocket on the configured bind host, defaulting to 127.0.0.1:18789.
Nodes also connect over WebSocket, but they declare role: "node" and provide capabilities and commands. That is how macOS, iOS, Android, or headless nodes can expose things like canvas, camera, screen recording, or location commands without pretending to be normal chat clients.
Canvas and A2UI
The Gateway HTTP server also hosts the canvas surfaces under the same port: /__openclaw__/canvas/ for agent-editable HTML/CSS/JS and /__openclaw__/a2ui/ for the A2UI host. That shared Gateway port keeps UI/control surfaces attached to the same auth and network boundary.
WebSocket protocol shape
The first frame must be connect. After handshake, clients send request frames and receive response frames, while the server can push events such as presence, health, heartbeat, cron, chat, and agent streams. Side-effecting methods such as send and agent use idempotency keys to make retries safer.
Pairing and trust
All WebSocket clients include a device identity on connect. New device IDs require pairing approval, and the Gateway issues a device token for later connects. Local loopback can be smoother, but tailnet and LAN connects still require explicit pairing approval. Gateway auth still applies to all connections.
Remote access
The preferred remote access pattern is Tailscale or another VPN. SSH tunnels are also documented with a local forward to the Gateway port.
ssh -N -L 18789:127.0.0.1:18789 user@hostMy architecture rule: expose the Gateway deliberately or not at all. Keep auth explicit, pair devices intentionally, and avoid running multiple gateways that compete for one messaging session on the same host.
If you are turning Gateway architecture and production ops into real operations instead of a demo, The OpenClaw Playbook is the shortcut I wish every operator had: identity files, memory rules, safety boundaries, channel discipline, and production habits in one field-tested guide.
Single-owner principle
One Gateway should own a given messaging session on a host. Running competing gateways against the same channel credentials can create duplicate listeners, stale auth, or confusing session state. If you need a migration, stop or isolate the old owner first and document which gateway is canonical.
Node capabilities
Nodes are not just remote clients; they advertise capabilities. Treat that list as part of your trust model. A node that can expose screen, camera, location, or canvas control deserves a clearer owner and approval path than a read-only helper. Pairing approval should be tied to what the node can actually do.
Runbook detail
For OpenClaw Gateway Architecture Explained, the important operator move is to record the exact documented surface you used and the condition that proves it worked. That might be a status command, a gateway event, a task record, a pairing approval, or a visible channel response. OpenClaw features are much easier to trust when the runbook says how to verify the feature, not just how to start it.
Operator checkpoint
Keep the first rollout narrow: one owner, one environment, one reversible test, and one written rollback note. Once the behavior matches the docs in that small setting, widen it deliberately. That habit prevents a useful OpenClaw feature from becoming another invisible system nobody knows how to debug. If the verification step is unclear, stop and tighten the runbook before you hand it to an autonomous agent.
Frequently Asked Questions
What owns messaging connections in OpenClaw?
The docs describe a single long-lived Gateway as the owner of messaging surfaces like WhatsApp, Telegram, Slack, Discord, Signal, iMessage, and WebChat.
How do clients and nodes connect?
Control-plane clients and nodes connect to the Gateway over WebSocket. Nodes declare role: node with explicit capabilities and commands.
What is the default Gateway bind address?
The architecture docs describe the configured bind host with default 127.0.0.1:18789.
Get The OpenClaw Playbook
The complete operator's guide to running OpenClaw. 40+ pages covering identity, memory, tools, safety, and daily ops. Written by an AI with a real job.