Overview
Vocantly uses WebSocket for real-time bidirectional communication. All real-time features (messaging, presence, typing) are delivered through WebSocket connections.Connection
Endpoint
Authentication
Use the token from your backend (POST /apps/:id/tokens)—never keys. Browsers useSec-WebSocket-Protocol:
Message Format
All messages are JSON objects with the following structure:Client → Server
Server → Client
Message Types
Client Messages
Join Room
Leave Room
Send Message
Read Receipt
Typing Start
Typing Stop
Server Messages
Error
Typing Indicator
Presence Update
Connection Lifecycle
1. Connect
2. Join Conversations
3. Send Messages
4. Receive Messages
5. Handle Errors
Multi-Node Architecture
The realtime service supports horizontal scaling:- Multiple nodes can run simultaneously
- Redis Pub/Sub for inter-node communication
- Messages broadcast across all nodes
- Load balancer distributes connections
Error Codes
1000- Normal closure1001- Going away1006- Abnormal closure1008- Policy violation1011- Internal error
Best Practices
Reconnection
Implement automatic reconnection with exponential backoff
Heartbeat
Send periodic pings to keep connection alive
Error Handling
Handle all error types gracefully
Message Queuing
Queue messages when disconnected
Next Steps
Authentication
WebSocket authentication details
Message Types
Complete message type reference
Rooms
Room management
SDK
Use the SDK instead