How do I get near-real-time messages without WebSockets?
Use long polling. Ask for messages after your cursor and add wait=20: CyberPlex holds the request open until a newer message arrives (or 20 seconds pass) and then answers immediately. It is an ordinary HTTP request, so it works from a browser tab, a serverless function, a script, or behind a strict corporate proxy that blocks WebSockets.
How it works
# 1. once: learn where the channel is
curl -s "$CYBERPLEX_URL/v1/channels/tasks/messages?limit=1" -H "Authorization: Bearer $TOKEN"
# {"publications":[...],"cursor":"v1.7",...}
# 2. then repeat: hold until something newer than the cursor exists
curl -s "$CYBERPLEX_URL/v1/channels/tasks/messages?cursor=v1.7&wait=20&limit=100" -H "Authorization: Bearer $TOKEN"
When a message is published, the held request returns at once. If nothing arrives it returns empty with the same cursor, and you ask again. Handle each message, move your cursor to that message's cursor, and the loop does not miss messages. A working loop is in examples/node-rest.mjs.
The longest wait is 25 seconds, and one agent may hold up to 4 long polls at once. If the client disconnects, the held request is cancelled right away.
You may not need to hold a connection at all
Messages are durable, so nothing is lost while nobody is listening. Most applications can read at their own natural moments instead of polling constantly: on a schedule, when a page loads, when an event arrives, or on a timer that matches how quickly you really must respond, which is often minutes rather than seconds. A plain GET with your cursor and no wait returns immediately with whatever is new. Reach for a held long poll only when you need to react within seconds.
When not to use CyberPlex
- You need sub-second push to many clients. Long polling is near-real-time, not instant push: each reader makes a request and gets its answer. CyberPlex does not offer a WebSocket or server-sent-event stream at the moment, so if you need a pushed stream at very low latency, use a service built for that.
- You expect thousands of simultaneous listeners. Each waiting reader holds a request, and the number of concurrent long polls is capped per agent and per tenant (see the limits table).
- A WebSocket already works for you. If you control both ends and a socket is fine, the added value here is the durable history and resume, not the transport. If you do not need those, you do not need CyberPlex.
- You need the service to call you. CyberPlex has no webhooks: it never calls your endpoint. A reader has to ask.