Runbook du service Gateway¶
Use this page for day-1 startup and day-2 operations of the Gateway service.
5-minute local startup¶
openclaw gateway --port 18789
# for full debug/trace logs in stdio:
openclaw gateway --port 18789 --verbose
# if the port is busy, terminate listeners then start:
openclaw gateway --force
# dev loop (auto-reload on TS changes):
pnpm gateway:watch
openclaw --profile main gateway install
openclaw --profile rescue gateway install
Healthy baseline: Runtime: running and RPC probe: ok.
openclaw channels status --probe
OPENCLAW_CONFIG_PATH when set).
Mode par défaut : gateway.reload.mode="hybrid" (application à chaud des changements sûrs, redémarrage pour les changements critiques).
Runtime model¶
- One always-on process for routing, control plane, and channel connections.
- Multiplexage sur un port unique.
- WebSocket control/RPC
- OpenResponses (HTTP) :
/v1/responses. - Control UI and hooks
- Default bind mode:
loopback. - Lâauthentification Gateway est requise par dĂ©faut : dĂ©finissez
gateway.auth.token(ouOPENCLAW_GATEWAY_TOKEN) ougateway.auth.password.
Port and bind precedence¶
| Setting | Resolution order |
|---|---|
| Gateway port | Priorité des ports : --port > OPENCLAW_GATEWAY_PORT > gateway.port > valeur par défaut 18789. |
| Bind mode | CLI/override â gateway.bind â loopback |
Hot reload modes¶
Désactiver avec gateway.reload.mode="off". |
Comportement keepalive |
|---|---|
off |
No config reload |
hot |
Apply only hot-safe changes |
restart |
Restart on reload-required changes |
hybrid (default) |
Hot-apply when safe, restart when required |
Operator command set¶
openclaw gateway status
openclaw gateway install
openclaw gateway stop
openclaw gateway restart
openclaw logs --follow
AccÚs distant¶
Tailscale/VPN recommandé ; sinon tunnel SSH : Fallback: SSH tunnel.
ssh -N -L 18789:127.0.0.1:18789 user@host
Les clients se connectent ensuite Ă ws://127.0.0.1:18789 via le tunnel.
connect.params.auth.token mĂȘme via le tunnel.
See: Remote Gateway, Authentication, Tailscale.
Supervision and service lifecycle¶
Use supervised runs for production-like reliability.
Pour redémarrer, utilisez `openclaw gateway restart` (ou `launchctl kickstart -k gui/$UID/bot.molt.gateway`).
LaunchAgent labels are ai.openclaw.gateway (default) or ai.openclaw.<profile> lors de lâexĂ©cution dâun profil nommĂ©. openclaw doctor audits and repairs service config drift.
systemctl --user enable --now openclaw-gateway[-<profile>].service
Activez le lingering (requis pour que le service utilisateur survive à la déconnexion/inactivité) :
sudo loginctl enable-linger youruser
Use a system unit for multi-user/always-on hosts.
sudo systemctl daemon-reload
sudo systemctl enable --now openclaw-gateway[-<profile>].service
Gateways multiples (mĂȘme hĂŽte)¶
Généralement inutile : un Gateway peut servir plusieurs canaux de messagerie et agents. Utilisez plusieurs Gateways uniquement pour la redondance ou une isolation stricte (ex. bot de secours).
Checklist par instance :
gateway.portuniqueOPENCLAW_CONFIG_PATHuniqueOPENCLAW_STATE_DIRuniqueagents.defaults.workspaceunique
Exemple :
OPENCLAW_CONFIG_PATH=~/.openclaw/a.json OPENCLAW_STATE_DIR=~/.openclaw-a openclaw gateway --port 19001
OPENCLAW_CONFIG_PATH=~/.openclaw/b.json OPENCLAW_STATE_DIR=~/.openclaw-b openclaw gateway --port 19002
Guide complet : Multiple gateways.
Profil dev (--dev)¶
openclaw --dev setup
openclaw --dev gateway --allow-unconfigured
# then target the dev instance:
openclaw --dev status
openclaw --dev health
Defaults include isolated state/config and base gateway port 19001.
Protocole (vue opérateur)¶
- First client frame must be
connect. - Gateway returns
hello-oksnapshot (presence,health,stateVersion,uptimeMs, limits/policy). - RequĂȘtes :
{type:"req", id, method, params}â{type:"res", id, ok, payload|error} - Common events:
connect.challenge,agent,chat,presence,tick,health,heartbeat,shutdown.
Agent runs are two-stage:
- Immediate accepted ack (
status:"accepted") - Les réponses
agentsont en deux Ă©tapes : dâabord un accusĂ©res{runId,status:"accepted"}, puis unresfinal{runId,status:"ok"|"error",summary}aprĂšs la fin de lâexĂ©cution ; la sortie streamĂ©e arrive sous forme deevent:"agent".
Documentation complĂšte : Gateway protocol et Bridge protocol (legacy).
Vérifications opérationnelles¶
KeepAlive : true¶
- Open WS and send
connect. - Expect
hello-okresponse with snapshot.
Readiness¶
`openclaw gateway health|status` â demander lâĂ©tat/la santĂ© via le WS du Gateway.
Gap recovery¶
Les événements ne sont pas rejoués. On sequence gaps, refresh state (health, system-presence) before continuing.
Common failure signatures¶
| Signature | Likely issue |
|---|---|
refusing to bind gateway ... without auth |
Non-loopback bind without token/password |
another gateway instance is already listening / EADDRINUSE |
Port conflict |
Gateway start blocked: set gateway.mode=local |
Config set to remote mode |
| Instantané de connexion | Auth mismatch between client and gateway |
For full diagnosis ladders, use Gateway Troubleshooting.
Garanties de sécurité¶
- Gateway protocol clients fail fast when Gateway is unavailable (no implicit direct-channel fallback).
- Les premiÚres trames non conformes ou le JSON malformé sont rejetés et la socket est fermée.
- ArrĂȘt gracieux : Ă©mettre lâĂ©vĂ©nement
shutdownavant la fermeture ; les clients doivent gérer la fermeture + reconnexion.
Related: