Overview
OpenClaw Gateway is a production-ready gateway server designed for orchestrating multiple AI agents at scale. Mission Control connects to OpenClaw Gateway via WebSocket for real-time session management, log streaming, and agent coordination.For simpler deployments, see CLI Integration for direct REST/SSE connections without a gateway.
Architecture
Key Features:- WebSocket Protocol v3: Binary-efficient, fully-typed messaging
- Device Identity Auth: Ed25519 signature-based authentication
- Session Management: Multi-session tracking with token accounting
- Real-time Logs: Structured log streaming from agents to UI
- Agent Spawning: On-demand process lifecycle management
- Heartbeat Protocol: 30s ping/pong with RTT tracking
Connection Protocol
1. WebSocket Handshake
Mission Control initiates a WebSocket connection with protocol negotiation:Send Connect Request with Device Auth
Mission Control signs the nonce with Ed25519 device identity:Signature Payload (v2 format):Signed using Ed25519 private key stored in browser
IndexedDB.2. Heartbeat Protocol
Mission Control sends ping requests every 30 seconds:- If 3 consecutive pongs are missed → force reconnect
- RTT (round-trip time) is calculated:
Date.now() - sentTimestamp - Displayed in Mission Control UI as connection latency
3. Event Stream
Gateway broadcasts real-time events:Session Update
Log Entry
Agent Status
Device Identity Authentication
What is Device Identity?
OpenClaw Gateway supports device-based authentication using Ed25519 cryptographic signatures. Each browser generates a unique device identity stored locally, preventing credential sharing and enabling per-device authorization.Security Benefits
- No password transmission over network
- Device-bound sessions cannot be hijacked
- Revocable per-device access
- Cryptographic proof of identity
User Experience
- Automatic authentication after first setup
- No password re-entry on reconnect
- Multi-device support (each device has unique identity)
- Transparent to user (happens in background)
Key Generation
On first connection, Mission Control generates an Ed25519 keypair:- Private key:
IndexedDB(non-extractable, browser-bound) - Public key: Sent to gateway during connect
- Device ID: UUID stored in
localStorage
Signature Process
- Gateway sends nonce in
connect.challenge - Mission Control builds signature payload:
- Sign payload using Ed25519 private key
- Send
signature+publicKey+noncein connect request - Gateway verifies signature using public key
- Returns
deviceTokenfor faster future reconnects
Device Token Caching
After successful authentication, gateway issues a device token:- Short-lived token (e.g., 24 hours)
- Can be used instead of full signature on reconnect
- Stored in
localStorageasmc_device_token - Automatically included in connect params
Gateway Configuration
Control UI Settings
Gateway must explicitly allow Mission Control origin:Device Auth Settings
requireSignature: true, Mission Control must provide device signature. HTTP-only deployments (without WebCrypto) will fail.
TLS Configuration
wss:// (WebSocket Secure).
Spawn Agents
Gateway can spawn agent processes on-demand:Error Handling
Non-Retryable Errors
Mission Control stops reconnecting for these errors:| Error | Cause | Solution |
|---|---|---|
origin not allowed | Origin not in allowedOrigins | Add your URL to gateway config |
device identity required | Gateway requires device auth, but browser doesn’t support WebCrypto | Use HTTPS or localhost |
device_auth_signature_invalid | Invalid Ed25519 signature | Clear device identity in browser DevTools → Application → IndexedDB |
auth rate limit | Too many auth attempts | Wait 1 minute, then reconnect |
- Error displayed in Mission Control logs panel
- Notification: “Gateway Handshake Blocked” with actionable help text
- Reconnect button disabled until error is resolved
Retryable Errors
Auto-reconnect with exponential backoff for:- Network errors (DNS, connection refused)
- WebSocket close codes (except 4001 non-retryable)
- Heartbeat timeout (3 missed pongs)
Deployment
Docker Compose
Systemd Service
Nginx Reverse Proxy
Proxy WebSocket connections through Nginx:Monitoring
Connection Health
Mission Control UI displays:- Connection Status: Connected / Disconnected / Reconnecting
- Latency: Real-time RTT from ping/pong (ms)
- Reconnect Attempts: Counter during reconnection
- Protocol Version: Negotiated protocol (should be 3)
Gateway Metrics
OpenClaw Gateway exposes Prometheus metrics:openclaw_gateway_connections_total- Active WebSocket connectionsopenclaw_gateway_messages_sent_total- Messages sent to clientsopenclaw_gateway_messages_received_total- Messages from clientsopenclaw_gateway_spawn_requests_total- Agent spawn requestsopenclaw_gateway_auth_failures_total- Failed authentications
Logs
Gateway structured logs:Troubleshooting
Connection stuck on 'Waiting for connect challenge...'
Connection stuck on 'Waiting for connect challenge...'
Cause: Gateway not sending
connect.challenge event.Debug:- Check gateway logs for connection attempt
- Verify gateway is running:
systemctl status openclaw-gateway - Test WebSocket manually:
- Check firewall rules allow port 8080
Device signature invalid
Device signature invalid
Error:
device_auth_signature_invalidSolutions:- Clear device identity:
- Chrome DevTools → Application → IndexedDB → Delete
device-identity
- Chrome DevTools → Application → IndexedDB → Delete
- Reconnect (triggers new key generation)
- Check browser console for WebCrypto errors
- Ensure HTTPS (or localhost) for WebCrypto access
Origin not allowed
Origin not allowed
Error: Restart gateway:
origin not allowedSolution:
Add Mission Control origin to gateway config:Frequent disconnections
Frequent disconnections
Cause: Network instability or proxy timeout.Solutions:
- Check Mission Control logs for error patterns
- Verify 30s heartbeats are being sent
- Increase proxy timeout (nginx:
proxy_read_timeout 300s) - Check for firewall/NAT issues
- Monitor RTT — high latency may indicate network issues
Agent spawn fails
Agent spawn fails
Error:
spawn_result with status: 'failed'Debug:- Check gateway has permissions to execute command
- Verify
cwdpath exists - Check agent script has execute permission:
chmod +x agent.py - Review gateway logs for spawn errors
- Test command manually:
Security Considerations
TLS Required
Always use WSS (WebSocket Secure) in production:Device auth requires HTTPS for WebCrypto API access.
Origin Whitelist
Limit Never use
allowedOrigins to trusted domains:* (wildcard) in production.Device Limits
Prevent device proliferation:Users must re-authenticate after token expiry.
Audit Logs
Enable gateway audit logging:
Related Docs
CLI Integration
Simpler REST/SSE alternative
WebSocket Client
Client implementation details
Authentication
API key and role-based auth