Establish SSE connection

Establishes a long-lived Server-Sent Events (SSE) connection to receive commands in real-time.

Stream Format

The stream sends newline-delimited messages. Each message is either:

  • Command: A JSON object containing a command to process (see Command schema)
  • Heartbeat: An SSE comment line starting with : to keep the connection alive

Heartbeat Messages

The server sends periodic heartbeat messages to keep the connection alive and prevent timeouts from proxies, load balancers, or firewalls. Heartbeats are sent as SSE comments in the format : \n (colon, space, newline).

  • Default heartbeat interval: 5 seconds (configurable server-side)
  • Clients MUST ignore lines starting with : (SSE comment lines)

Connection Lifecycle

The server maintains the connection indefinitely until:

  • The client disconnects
  • A network error occurs
  • The server is shut down

The server does NOT close the connection due to inactivity. Clients should implement their own reconnection logic in case of network failures.

Client Implementation Notes

  • Parse each line from the stream
  • Skip lines starting with : (heartbeats/comments)
  • Parse remaining lines as JSON Command objects
  • Implement automatic reconnection on connection loss
Language
Response
Click Try It! to start a request and see the response here!