WebSocket Endpoint
Sockudo implements the Pusher WebSocket protocol. Connect to the WebSocket endpoint using your application key:Connection Parameters
Optional query parameters can be included:Protocol version (currently version 7)
Client library name (e.g., “pusher-js”)
Client library version
Connection Handshake
When a WebSocket connection is established, the server immediately sends apusher:connection_established event:
Always
pusher:connection_establishedJSON-encoded string containing connection details
Unique identifier for this connection in the format
high.low (e.g., “123456.789012”)Number of seconds before the connection is considered inactive (default: 120)
Socket ID
Thesocket_id is a unique identifier for each WebSocket connection:
- Format: Two random integers separated by a period (e.g., “1234567890.9876543210”)
- Used for authentication signatures on private/presence channels
- Required when publishing client events
- Automatically generated by the server
Keep-Alive Protocol
Sockudo uses ping/pong frames to keep connections alive:Server-Initiated Ping
The server may send apusher:ping event to check connection health:
pusher:pong event:
Client-Initiated Ping
Clients can also sendpusher:ping to verify the connection is active. The server will respond with pusher:pong.
Error Handling
The server sends error messages in this format:Error code (4000-4999 range)
Human-readable error description
Channel name if the error is channel-specific, otherwise null
Common Error Codes
| Code | Description |
|---|---|
| 4000 | Generic error |
| 4001 | Application does not exist |
| 4004 | Application disabled |
| 4005 | Origin not allowed |
| 4009 | Connection timeout |
| 4100 | Buffer full - slow consumer disconnected |
Example: Connecting with pusher-js
Connection Lifecycle
- Client opens WebSocket connection to
/app/{appKey} - Server validates the application key
- Server sends
pusher:connection_establishedwithsocket_id - Connection is active - client can now subscribe to channels
- Server may send periodic
pusher:pingframes - Client responds with
pusher:pongto maintain connection - Connection remains open until closed by client or server