Realtime Troubleshooting Guide¶
Solutions to common issues when working with Centrali Realtime.
Connection Issues¶
Connection Fails Immediately¶
Symptoms: - onError callback fires immediately - Error code: MISSING_TOKEN, INVALID_TOKEN, or WORKSPACE_MISMATCH
Solutions:
-
Check token is provided:
-
Verify token is valid:
-
Check workspace matches:
Connection Drops Frequently¶
Symptoms: - onDisconnected callback fires repeatedly - Events stop arriving, then resume
Solutions:
- Check network stability:
- Test with other SSE connections
- Check for proxy/firewall issues
-
Verify SSL certificate is valid
-
Monitor reconnection behavior:
-
Check for connection timeout:
- Connections close after 1 hour by default
- SDK automatically reconnects
- If timeouts are too frequent, check server configuration
Rate Limit Exceeded¶
Symptoms: - Error code: RATE_LIMIT_EXCEEDED - HTTP status: 429
Solutions:
- Check current plan limits:
- Free tier: 10 concurrent connections per workspace
- Standard tier: 100 concurrent connections per workspace
- Pro tier: 1,000 concurrent connections per workspace
-
Enterprise: Custom limits
-
Reduce connection count:
// Bad: Multiple subscriptions for same events const sub1 = centrali.realtime.subscribe({ structures: ['order'], onEvent: handle1 }); const sub2 = centrali.realtime.subscribe({ structures: ['order'], onEvent: handle2 }); // Good: Single subscription with combined handler const subscription = centrali.realtime.subscribe({ structures: ['order'], onEvent: (event) => { handle1(event); handle2(event); } }); -
Implement connection pooling for server-side applications:
// Singleton pattern for shared realtime connection class RealtimePool { private static instance: RealtimeSubscription; private static handlers: Set<EventHandler> = new Set(); static subscribe(handler: EventHandler) { this.handlers.add(handler); if (!this.instance) { this.instance = centrali.realtime.subscribe({ onEvent: (event) => { this.handlers.forEach(h => h(event)); } }); } return () => this.handlers.delete(handler); } }
Event Issues¶
Not Receiving Any Events¶
Symptoms: - Connection succeeds (onConnected fires) - No events received despite data changes
Solutions:
-
Verify events are being generated:
-
Check structure filter:
-
Check event type filter:
-
Verify CFL filter syntax:
Missing Events During Reconnection¶
Symptoms: - Events are missed when connection drops and reconnects
Explanation: Realtime is a "live" stream - events during disconnection are not replayed. This is by design for v1.
Solutions:
-
Implement gap detection:
let lastEventTime: Date | null = null; centrali.realtime.subscribe({ onConnected: async () => { if (lastEventTime) { // Fetch records modified since last event const missed = await centrali.queryRecords('order', { filter: `updatedAt > ${lastEventTime.toISOString()}` }); missed.data.forEach(processRecord); } }, onEvent: (event) => { lastEventTime = new Date(event.timestamp); processEvent(event); } }); -
Use periodic sync:
Duplicate Events¶
Symptoms: - Same event received multiple times
Explanation: During reconnection or in rare network conditions, events may be duplicated.
Solution: Implement idempotent event handling:
const processedEvents = new Set<string>();
centrali.realtime.subscribe({
onEvent: (event) => {
// Create unique key for event
const eventKey = `${event.recordId}-${event.timestamp}`;
if (processedEvents.has(eventKey)) {
console.log('Duplicate event ignored:', eventKey);
return;
}
processedEvents.add(eventKey);
// Prevent memory leak - keep last 1000 events
if (processedEvents.size > 1000) {
const oldest = processedEvents.values().next().value;
processedEvents.delete(oldest);
}
processEvent(event);
}
});
Authentication Issues¶
Token Expired During Session¶
Symptoms: - Error code: TOKEN_EXPIRED - Connection was working, then failed
Solution: Implement token refresh:
centrali.realtime.subscribe({
onError: async (error) => {
if (error.code === 'TOKEN_EXPIRED') {
// Refresh your token
const newToken = await refreshAuthToken();
centrali.setToken(newToken);
// SDK will automatically reconnect with new token
}
},
onEvent: handleEvent
});
Service Account Token Issues¶
Symptoms: - Client credentials aren't working - Error fetching initial token
Solutions:
-
Verify credentials:
// Test credentials directly const tokenResponse = await fetch('https://api.centrali.io/iam/oauth/token', { method: 'POST', headers: { 'Content-Type': 'application/x-www-form-urlencoded' }, body: new URLSearchParams({ grant_type: 'client_credentials', client_id: process.env.CENTRALI_CLIENT_ID, client_secret: process.env.CENTRALI_CLIENT_SECRET, scope: `workspace:${workspaceId}` }) }); console.log(await tokenResponse.json()); -
Check service account permissions:
- Ensure the service account has
realtime:subscribepermission - Verify workspace access is granted
Filter Issues¶
Filter Not Working¶
Symptoms: - Receiving events that should be filtered out - No events received with valid-looking filter
Solutions:
-
Verify field path:
-
Check operator syntax:
-
Test filter values:
Invalid Filter Error¶
Symptoms: - Connection fails with 400 error - Error message mentions "invalid filter"
Solutions:
- Check for valid operators:
- Valid:
eq,ne,gt,lt,gte,lte,in,nin,contains,startswith,endswith -
Invalid:
=,!=,>,<,like,matches -
Escape special characters:
Performance Issues¶
High Memory Usage (Browser)¶
Symptoms: - Memory increases over time - Browser becomes slow
Solutions:
-
Clean up subscriptions:
-
Limit stored events:
High CPU Usage¶
Symptoms: - Constant CPU activity - Many reconnection attempts
Solutions:
-
Check for reconnection loop:
-
Reduce event volume:
Debug Mode¶
Enable debug logging for detailed troubleshooting:
// In browser console
localStorage.setItem('DEBUG', 'centrali:*');
// Or check connection state
const sub = centrali.realtime.subscribe({...});
console.log('Connected:', sub.connected);
Getting Help¶
If you're still experiencing issues:
- Check status page for service incidents
- Review API logs in your Centrali dashboard
- Contact support with:
- Error codes and messages
- SDK version
- Browser/Node.js version
- Steps to reproduce
Related Documentation¶
- Quickstart - Basic setup guide
- Authentication - Token management
- Filtering - CFL filter syntax
- API Reference - HTTP API details