Subscribing to Events
Section titled “Subscribing to Events”Polling is the wrong tool for “tell me when something changes”. The platform’s push channel is the public socket — the web-socket-service, a Socket.IO server that turns domain events into room-scoped pushes. Real-Time (Sockets & RTC) owns that service’s full story: the event catalogue, the RabbitMQ bridge behind it, scaling, and the browser integration. This page covers the part that guide does not: connecting from a non-browser client — a worker, a daemon, your own backend — where the credential question and the reconciliation discipline look different.
One framing rule before anything else: the channel is push-only and best-effort. You subscribe and receive; you never write through it, and you never treat it as a complete log. Every write, and every authoritative read, is an HTTP call.
The channel and the protocol
Section titled “The channel and the protocol”The endpoint speaks Socket.IO v4 (socket.io ^4.8.1), which is its own protocol on top of WebSocket/HTTP long-polling — a bare WebSocket client cannot connect. From a non-browser process, use a Socket.IO v4-compatible client; official and community implementations exist for JavaScript, Python, Java, Go, .NET and others, and everything on this page is client-library-agnostic: an auth payload at handshake, named events in both directions.
The service is a standalone Express + Socket.IO process, listening on port 3017 by default. It is deployed and exposed separately from the /api gateway path — the gateway’s route table (api-gateway/config/kong.yml) carries no socket route — so the socket host is a property of your deployment. Obtain it from whoever operates your environment, alongside your base URL. CORS on the server is origin: '*', which is irrelevant to a non-browser client anyway.
Authenticating the handshake
Section titled “Authenticating the handshake”Authentication happens once, in a handshake middleware, and the credential goes in the Socket.IO auth payload under the key token (setupSocketAuthMiddleware):
import { io } from "socket.io-client";
const socket = io("https://<socket-host>", { auth: { token: accessToken },});Here is the trap for a headless client: this must be an OAuth 2.0 access token, not an API token. The server validates the credential by posting it — with its own CLIENT_ID/CLIENT_SECRET — to the identity provider’s token-introspection endpoint and requires an active: true answer. An API token is a different credential validated by a different endpoint (the gateway’s app-token-auth plugin against /identity/api-token/validate — api-gateway/config/kong.yml); it does not introspect as an active OAuth token, so it cannot open the socket. A service that authenticates its HTTP calls with x-app-token therefore needs a second credential for the socket: a user’s OAuth token, which for a service means the password grant for a dedicated service account. That account must be an ordinary user (NORMAL_USER): an APPLICATION_USER is held only as an API token, has no sign-in record, and the password grant answers invalid_grant for it. A client_credentials token is not a substitute. It introspects as active, so the socket opens, but it has no sub: socket.userId stays unset, and subscribeToNotifications answers error {message: 'User ID is required'} and disconnects. Choosing a credential covers the trade-offs.
On success the server binds your identity: socket.userId is set from the token’s sub, and that identity — not anything you send later — decides which user room you may join. An invalid or inactive token rejects the connection with Invalid token, surfaced to your client as a connect_error.
Two lifecycle consequences of “validated once, at handshake”:
- There is no per-message re-authentication, and an already-open socket is not torn down when its token later expires.
- Every reconnection is a new handshake. A long-lived client whose token has meanwhile expired will fail to reconnect. Refresh the token before the retry — with
socket.io-client, assignsocket.auth = { token: freshToken }inside areconnect_attempt(orconnect_error) handler.
Rooms: subscribe before anything arrives
Section titled “Rooms: subscribe before anything arrives”A freshly connected socket receives nothing. Delivery is scoped to rooms, and you opt in by emitting a subscribe event; each subscribe is answered by an acknowledgement event confirming the join (setupSocketHandlers):
| Room | Join by emitting | Payload | Acknowledgement |
|---|---|---|---|
user:{userId} — your notifications | subscribeToNotifications | (none — identity comes from the handshake) | subscribedToNotifications |
entries/{entityId}_{entryId} — one entry | entries/subscribe-to-entry | {entityId, entryId} | subscribedToEntry |
job:{messageId} — one async job | subscribeToJobExecution | {messageId} | subscribedToJobExecution |
Matching unsubscribe events exist for the entry and job rooms; missing payload fields produce an error event instead of a join. Wait for the acknowledgement before assuming you are in the room — some join failures are swallowed server-side and produce no error at all, a caveat Real-Time documents. What arrives in each room — entry value updates, workflow and comment events, notifications, job completions — is the event catalogue that guide owns; do not hardcode assumptions beyond the event names you actually consume.
Two things arrive without a room join, and a headless client should expect both. A few events are broadcast to every socket of the tenant — the icon-set and request-entry notices, and Since 1.10 packages/changed when a package’s review or store state moves (a signal to re-read, carrying only the packageId). And notifications are not filtered by space on the socket: your user room receives notifications raised in every space you belong to. Since 1.10 the shipped web client hides those from other spaces itself, but that filter is client-side only — filter on the notification entry’s value.space if your client works in one space (Real-Time).
Following a job you started over HTTP
Section titled “Following a job you started over HTTP”The subscription most useful to a headless client is the job room, because it replaces a polling loop. The pattern, end to end:
import { io } from "socket.io-client";
const socket = io(SOCKET_HOST, { auth: { token: oauthToken } });
socket.on("connect", () => { // messageId came back from an async HTTP operation, e.g. a bulk update socket.emit("subscribeToJobExecution", { messageId });});
socket.on("subscribedToJobExecution", ({ messageId }) => { console.log("watching job", messageId);});
socket.on("osos/infrastructure/job-executed", (evt) => { // evt: { messageId, userId, messages, result: { success, error?, result? } } if (evt.messageId !== messageId) return; finish(evt.result);});The completion event is emitted to both the job room and your user room (sendJobExecutionFinished), and its payload carries the job’s outcome object. Treat it as a wake-up call, not as the record: confirm the terminal state over HTTP with the job-status endpoint, which is the authoritative source — the division of labour is described in Long-running work.
Subscribe before or immediately after kicking off the work, not when you get bored of waiting: if the job finishes before your join completes, the room emit has already happened and nothing is replayed.
Delivery guarantees and reconciliation
Section titled “Delivery guarantees and reconciliation”Design your client around what the transport actually promises, which is little:
- Best-effort, no replay. Events are emitted to whoever is in the room at that moment. Entry-room emits are skipped entirely when the room has no subscribers (
sendDataToEntryreturns early), and nothing is queued for you while you are disconnected. - Reconnection is a gap. After any disconnect, assume you missed events: re-subscribe to your rooms (joins do not survive a new connection) and reconcile state with an HTTP read — refetch the entry, re-poll the job status.
- At-least-once handling. A job completion can reach you twice — once via the job room, once via your user room. Key your handling on
messageIdand make it idempotent. - Ordering is not contractual. Treat each event as “something changed, verify over HTTP” rather than as a delta to apply blindly.
This is the same posture the platform’s own UI takes: the socket makes it fast; HTTP makes it true.
What this channel is not
Section titled “What this channel is not”- Not a write path. No client-to-server event mutates data; anything that looks like a command over the socket is ignored by this service. Writes go through the HTTP API.
- Not a service-to-service channel.
web-socket-serviceis the platform’s only socket. Older releases also ran an internal relay between backend services (socket-service); it was removed in 1.10Removed 1.10, and backend services now follow jobs over the message bus. Pages written for 1.8 may still describe it. - Not a message queue. If you need durable, replayable integration events, poll the HTTP surface or build on webhooks and integrations — do not try to make the socket into one.
Platform 1.10.0 · Backend 1.11.0-alpha.11 · Frontend 1.11.0-alpha.6 · Mobile 1.10.2 · Chart 1.11.8 · Gateway 2.6.11 · MCP 0.2.0 · Grafana DS 1.2.0Docs build 2026-11-27