Update authentication
The auth endpoint and callback pattern have both changed.
Before:After:
| Ably (old) | Centrifugo (new) | |
|---|---|---|
| Endpoint | GET /user/token | GET /user/realtime-token/api-key |
| Callback | authCallback(tokenParams, callback) | getToken: async () => token |
| WS URL | Managed by SDK | wss://realtime.sx.bet/connection/websocket |
getToken is called automatically on initial connect and on token refresh — no manual token management needed. To signal a permanent auth failure (so the client stops retrying), throw UnauthorizedError from centrifuge on a 401/403 response. Any other thrown error is treated as transient and retried with backoff. See Real-time Data → Auth for the full pattern.Update channel subscriptions
The subscription API has changed. Message data moves from After:
message.data to ctx.data.Before:rewind is replaced by positioned + recoverable. These two flags together give you at-least-once delivery with automatic gap recovery on reconnect — equivalent to what rewind was doing, but more reliable. See Real-time Data → Recovery & reliability for how to handle the three reconnect states.Update channel names
All channel names have changed. Update every channel string in your code:
All message payloads are unchanged.
| Old channel (Ably) | New channel (Centrifuge) | Notes |
|---|---|---|
active_orders_v2:{baseToken}:{maker} | active_orders:{maker} | baseToken removed, _v2 dropped |
order_book_v2:{baseToken}:{marketHash} | order_book:market_{marketHash} | baseToken removed |
| — | order_book:event_{sportXEventId} | New — alternative to order_book:market_ that covers every market in an event with a single subscription |
best_odds:{baseToken} | best_odds:global | baseToken removed from channel name |
markets | markets:global | Renamed |
recent_trades | recent_trades:global | Renamed |
recent_trades_consolidated | recent_trades_consolidated:global | Renamed |
main_line | main_line:global | Renamed |
fixtures:fixture_update | fixtures:global | Renamed |
live_scores:{sportXEventId} | fixtures:live_scores | Now global — filter by sportXEventId client-side |
ce_refunds:{user} | ce_refunds:{bettor} | Parameter renamed user → bettor |
markets:parlay | parlay_markets:global | Renamed |
live_scores is now a global channel. The old live_scores:{sportXEventId} channel was per-event. The new fixtures:live_scores delivers all live score updates globally — filter the sportXEventId field in the payload to isolate the events you care about.Replace rewind with the snapshot + subscribe pattern
The Ably After:For channels with no history (
rewind parameter (which replayed recent messages automatically on subscribe) has no direct equivalent in Centrifugo. The replacement is to set positioned: true and recoverable: true on the subscription, then seed from REST inside the subscribed handler — which fires on every connect and tells you whether history replay already filled the gap.Before:best_odds:global, parlay_markets:global), omit the flags and always seed from REST in the subscribed handler — recovery is not available for those channels. See Real-time Data → Recovery & reliability for the full three-state logic.Further reading
- Real-time Data → — connecting, subscribing, recovery, and common failures
- WebSocket Channels → — namespace history capabilities and connection limits
- WebSocket Initialization → — full connection reference
