• HOME
  • Introducing Catalyst Data Streams: Real-time, ordered messaging over WebSocket

Introducing Catalyst Data Streams: Real-time, ordered messaging over WebSocket

Catalyst Data Streams is a new service in Catalyst CloudScale for pushing live updates to every screen that needs them. Your server publishes a message once, and every connected subscriber receives it over a WebSocket connection, in the order it was published. This blog covers how delivery works, who's allowed to listen, and how to build it in three steps.

Live updates before Data Streams

Until now, you had two ways to get live updates to a screen:

Polling. Every screen asks the server for updates every few seconds. It works, but each update shows up as late as the gap between asks, and your backend answers "nothing new" all day long for every screen.

Running your own WebSocket server. You can push updates the moment they happen, but you have to own everything that comes with it. You track who's connected, handle reconnects, work out what a screen missed while it was offline, and keep several servers in sync.

Data Streams gives you the second option without a server to run.

What is Catalyst Data Streams?

Data Streams is a publish/subscribe (pub/sub) service in Catalyst CloudScale. Your backend publishes a message to a channel, and every subscriber connected to that channel receives it over a WebSocket connection, in the order it was published. Use it for live dashboards, order and delivery tracking, in-app notifications, shared status boards, and device updates.

It comes down to three ideas:

  • Channel. The named stream that publishers write to and subscribers listen on. You create it once in the Catalyst console or ask your AI coding agent to create one through the Catalyst Model Context Protocol (MCP) server.
  • Publisher. Whatever sends messages into the channel, like an Advanced I/O function, an AppSail app, an external system calling the REST API, or a Catalyst Signals rule.
  • Subscriber. Whatever listens, whether it's a webpage, a mobile app, a back-end service, or a device. Each one holds a WebSocket connection open to the channel.

How delivery works: Ordered, acknowledged, and kept for 48 hours

Being fast is the easy part. These three rules are what make delivery reliable.

  1. Every subscriber gets every message in the same order. Message two never arrives before message one.
  2. No subscriber skips ahead. When a subscriber receives a message, it sends back an acknowledgement (sendAck()). The channel waits for that before it delivers the next message to that subscriber. If a subscriber is busy, the next messages are queued and delivered in order.
  3. Messages are kept for 48 hours. When a subscriber connects, it chooses where to start: live from now, from the oldest message still held, or from where its last session left off. The subscribe guide lists every option.

Who's allowed to listen: Tokens and access control

Can anyone subscribe to your channel? No. Every WebSocket connection needs a token pair, and only your server can create one. Token generation needs admin-level credentials, so it never runs in a browser.

When you create a channel, you choose how tokens are issued:

  • User Roles. For signed-in users of your app through Catalyst Authentication. You pick which roles can subscribe.
  • Custom Logic. For everything else, such as devices, API keys, single sign-on (SSO), or anonymous sessions. One Advanced I/O function you link to the channel runs your checks and issues the tokens.

One thing to know early: A token controls whether a client can listen, not what it hears. Everyone on a channel receives every message. If two groups need different messages, give them two channels. The access control guide covers both modes.

Build it in three steps

The examples below use the Node.js SDK (npm install @zcatalyst/datastreams @zcatalyst/auth). Java and Python SDKs offer the same operations.

1. Issue a token to each client

This Advanced I/O function is set as the channel's Custom Logic source. It checks a per-client API key before it issues a token:

const { zcAuth } = require('@zcatalyst/auth');
const { DataStreams } = require('@zcatalyst/datastreams');

const CHANNEL_ID = process.env.CHANNEL_ID;
const CLIENT_KEYS = JSON.parse(process.env.CLIENT_KEYS); // {"client-a":"...","client-b":"..."}

module.exports = async (req, res) => {
  const clientId = req.headers['x-client-id'];

  // Custom Logic means your rules decide who gets a token. Here: a per-client API key.
  if (!clientId || CLIENT_KEYS[clientId] !== req.headers['x-client-key']) {
    res.writeHead(403);
    return res.end();
  }

  const datastreams = new DataStreams(await zcAuth.init(req));

  // Custom Logic channels issue tokens by connection name, from this function only
  const token = await datastreams.getTokenPair(CHANNEL_ID, { connectionName: clientId });

  res.writeHead(200, { 'Content-Type': 'application/json' });
  res.end(JSON.stringify(token)); // { url, 'wss-id', key, 'channel-id' }
};

2. Publish when your data changes

When a record changes, your backend saves it first and then publishes it:

// After the record is written to the Data Store
await datastreams.publishData(
  CHANNEL_ID,
  JSON.stringify({ type: 'record.updated', version: 1, record }) // the payload must be a string
);

3. Subscribe on every client

The JavaScript SDK runs in the browser for subscribers:

import { DataStreamsWebSocket } from '@zcatalyst/datastreams';

const token = await fetch('/server/datastreams_token/', {
  headers: { 'x-client-id': CLIENT_ID, 'x-client-key': CLIENT_KEY }
}).then((r) => r.json());

const ws = new DataStreamsWebSocket({ url: token.url, zuid: token['wss-id'], key: token.key });

ws.on('open', () => ws.subscribe('0')); // live, from now

ws.on('message', (msg) => {
  applyUpdate(JSON.parse(msg.data)); // handle it first...
  ws.sendAck();                      // ...then acknowledge, so the next message comes through
});

Handle the message first, then acknowledge it. If the client crashes before it acknowledges, that message still counts as undelivered. The client receives it again only if it reconnects with the resume type, subscribe('-2'), instead of '0'.

That's the whole loop: a token, a publish, a subscribe, and an acknowledgement. For the full options, see generate a token pair, publish data with the SDK, and subscribe over WebSocket.

Publish without writing code: Catalyst Signals

Not every event starts in your code. Catalyst Signals routes events from Catalyst services, Zoho apps such as Zoho CRM and Zoho Desk, or custom webhooks straight into a channel. A new deal in Zoho CRM can then show up on a sales dashboard with no publishing code at all.

Test it before you write code

Every channel opens on a Test Data Flow tab, where you can publish a sample message and watch the console receive and acknowledge it. Test messages are real messages, so any subscribers your app already has will receive them too. See test the data flow in the console.

When Data Streams is the wrong tool

It fits anywhere people need to see the same changes, in order, as they happen. It isn't built for states that change 60 times a second, like player positions in a game. Each subscriber acknowledges every message before it gets the next, so Data Streams favors correctness over raw speed. Each channel supports up to 1,000 live subscribers and messages up to 100 KB.

Get started

Data Streams handles the hard parts of live updates for you: ordered delivery, acknowledgements, 48 hours of replay, and token-based access. Create a channel, send a test message from the console, and connect your first subscriber with the code above.

Related Topics

Leave a Reply

Your email address will not be published. Required fields are marked

By submitting this form, you agree to the processing of personal data according to our Privacy Policy.