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 use Sec-WebSocket-Protocol:
Node.js (custom headers):

Message Format

All messages are JSON objects with the following structure:

Client → Server

Server → Client

Message Types

Client Messages

Join Room

Response:

Leave Room

Response:

Send Message

Broadcast (to all room members):

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 closure
  • 1001 - Going away
  • 1006 - Abnormal closure
  • 1008 - Policy violation
  • 1011 - 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