Skip to main content
What this is for: how to connect, authenticate, and keep a WebSocket session open against the Comis daemon. Who it’s for: developers building real-time clients (dashboards, custom CLIs, browser apps). Complete reference for the Comis WebSocket protocol. The gateway exposes a WebSocket endpoint at /ws for JSON-RPC 2.0 communication. This is the primary transport for the CLI and web dashboard.

Connection

Connect to the WebSocket endpoint with authentication to establish a JSON-RPC session.

Connection Examples

If authentication fails, the server accepts the WebSocket upgrade but immediately closes the connection with close code 4001 (Unauthorized).

Protocol

All communication uses JSON-RPC 2.0 over text WebSocket frames. Binary frames are not supported and will receive a parse error response.

Request/Response Exchange

Every request must include:
  • "jsonrpc": "2.0" — protocol version (required)
  • "method" — the method name in namespace.method format
  • "id" — a unique request identifier (integer or string)
  • "params" — method parameters (optional, defaults to {})
The server responds with the same id to correlate request and response. Notifications (requests without id) do not receive a response.

Batch Requests

Send an array of JSON-RPC requests to execute multiple methods in a single message. Responses are returned as an array in the same order.
The maximum batch size is configurable via gateway.maxBatchSize. Exceeding the limit returns a -32600 error.

Heartbeat

The server sends periodic heartbeat notifications to all connected clients. Heartbeats are JSON-RPC notifications (no id field) and do not require a response.
Heartbeats serve as a keep-alive mechanism, preventing proxy timeouts and allowing clients to detect stale connections.

Rate Limiting

Each WebSocket connection has an independent sliding-window rate limiter that tracks message frequency. When the rate limit is exceeded, the server responds with an error and discards the message:
The rate limit resets as messages age out of the sliding window. No backoff or retry-after header is provided — clients should reduce their message frequency.

Message Size Limit

Messages exceeding the configured maximum size are rejected before parsing.

Error Codes

JSON-RPC error codes returned by the WebSocket handler. All error responses follow the JSON-RPC 2.0 error format:

Close Codes

WebSocket close codes used by the Comis gateway. The server sends close code 1001 with reason "Server shutting down" during graceful shutdown, giving clients time to reconnect after restart.

Server Notifications

The server can push unsolicited notifications to connected clients. Notifications are JSON-RPC messages without an id field — clients must not send a response.

Targeted Notifications

The server can send notifications to a specific client (identified by clientId from the token configuration):

Broadcast Notifications

Some notifications (such as sub-agent completion announcements) are broadcast to all connected clients when the target client cannot be determined.
Clients should handle unknown notification methods gracefully by ignoring them. New notification types may be added in future versions.

JSON-RPC Methods

All available JSON-RPC methods with parameters and examples

HTTP Gateway

HTTP endpoint reference and authentication

Rate Limiting

Rate limiting configuration and behavior

Config YAML

Gateway configuration options