On this page
Realtime
What a channel is, how clients connect, and where to go next.
A Realtime Channel is an ordered stream of messages in one environment. Your server publishes to it with a key; every connected browser, app or device receives each message as it is appended, and a client that drops resumes from the last message it saw. Realtime is part of Sylphx Events: there is nothing to deploy, one key in your project is enough.
What a channel gives you
- Ordered history. Every message gets a
sequence(from 1, gap-free) and acursor, and is kept for the channel'sspec.history_retention: 24 hours by default, at most 7 days. - Resume, not replay by hand. A client that reconnects sends its last
cursor and receives exactly the messages after it. Server-Sent Events clients
do this on their own through
Last-Event-ID. - Two transports.
status.connect_uriis a WebSocket that pushes messages and carries presence;status.stream_uriis Server-Sent Events, for clients that only read. - Clients hold no secret. Your server mints a short-lived token
(
rtt_…, at most an hour) for one channel, and the client connects with it. A channel withspec.publishable_okalso admits a publishable key. - Presence. A token that names a client id puts that client in the
channel's members while it is connected, and
the channel carries
presence.enterandpresence.leavemessages. - Idempotent publish. A publish retried with the same
Idempotency-Keyreturns the first message instead of appending a second.
Names and ids
- Channel
- orgs/{org}/projects/{project}/envs/{env}/realtime_channels/{realtime_channel}
- Channel id
- rtc_<cell><ulid>
- Message
- …/realtime_channels/{realtime_channel}/realtime_messages/{realtime_message}
- Message id
- rtm_<cell><ulid>
- Subscribe token
- rtt_…
The scopes
events:write— creating, changing and deleting a channel.events:publish— publishing a message, and minting a subscribe token.events:read— reading channels, their message history and their members.events:realtime:subscribe— connecting to a channel's stream with a key instead of a token. A publishable key may hold it, for channels that allow publishable keys. Keys and scopes covers the two kinds of key.