Overview
Vocantly provides real-time features through WebSocket connections. The realtime service handles instant message delivery, presence tracking, typing indicators, and more.WebSocket Connection
Connection Endpoint
Authentication
Use the token from your backend (never keys). Browsers useSec-WebSocket-Protocol:
Connection Lifecycle
Connection States
Automatic Reconnection
The SDK automatically handles reconnection with exponential backoff:- Initial reconnect: 1 second
- Max delay: 30 seconds
- Max retries: Unlimited
Joining Conversations
To receive messages for a conversation, you must join it:Sending Messages
Message Format
Using SDK
Receiving Messages
Messages are broadcast to all connected clients in the conversation:Presence
Track user online/offline status:Update Presence
Presence has two states:online and offline. It’s tracked automatically — a user
is online while connected and offline when they disconnect.
Listen for Presence Updates
WebSocket Protocol
Typing Indicators
Show when users are typing:Start Typing
Stop Typing
Receive Typing Indicators
Typing indicators automatically expire after 5 seconds if not explicitly stopped.
Read Receipts
Track when messages are read:Send Read Receipt
Receive Read Receipts
Message Types
Client → Server
join- Join a conversation roomleave- Leave a conversation roommessage- Send a messageread- Mark message as readtyping_start- Start typing indicatortyping_stop- Stop typing indicator
Server → Client
joined- Successfully joined roomleft- Successfully left roommessage- New message receivedreceipt- Receipt updatetyping- Typing indicator updatepresence- Presence updateerror- Error message
Error Handling
Connection Errors
Message Errors
Multi-Node Architecture
The realtime service is horizontally scalable:- Multiple nodes can run simultaneously
- Redis Pub/Sub for inter-node communication
- Messages broadcast across all nodes
- Load balancer distributes connections
Performance Considerations
Connection Pooling
Reuse WebSocket connections when possible
Room Management
Leave rooms when not needed to reduce overhead
Message Batching
Batch operations when possible
Error Recovery
Implement robust error handling and reconnection
Next Steps
WebSocket Protocol
Complete WebSocket protocol reference
Presence & Typing
Presence and typing indicators
SDK Realtime
SDK real-time features
Troubleshooting
Common issues and solutions