Documentation Index
Fetch the complete documentation index at: https://mintlify.com/sockudo/sockudo/llms.txt
Use this file to discover all available pages before exploring further.
Overview
Channels are the core concept in Sockudo for organizing real-time message delivery. Clients subscribe to channels to receive events, and publishers send messages to channels to reach all subscribers. Sockudo supports multiple channel types, each with different security and feature characteristics.Channel Types
Public Channels
Public channels are open to any connected client without authentication. Naming: No special prefix required- Live sports scores
- Stock ticker updates
- Public notifications
- News feeds
Private Channels
Private channels require authentication before clients can subscribe. The server validates that a client is authorized to access the channel. Naming: Must start withprivate-
- Authentication required - Server validates subscription requests
- Client events - Clients can trigger events to other channel members
- Selective access - Control who can subscribe per channel
- Private user notifications
- Direct messaging
- Team collaboration spaces
- Private dashboards
Presence Channels
Presence channels extend private channels with member tracking. The server maintains a list of subscribed users and notifies all members when someone joins or leaves. Naming: Must start withpresence-
- All private channel features
- Member list - See all currently subscribed users
- Join/leave events - Automatic notifications when members change
- User info - Associate custom data with each member
- Each unique
user_idappears once in the member list - Multiple connections from the same user count as one member
- Member is removed only when their last connection leaves
- Chat rooms with online indicators
- Collaborative editing (show active editors)
- Multiplayer games (player list)
- Live webinars (attendee list)
Private Encrypted Channels
Private encrypted channels provide end-to-end encryption where message payloads are encrypted by the client before sending and decrypted by receiving clients. The server cannot read message contents. Naming: Must start withprivate-encrypted-
- All private channel features
- End-to-end encryption - Server never sees plaintext
- Client-side encryption - Encryption keys never leave the client
- Perfect forward secrecy - Each message uses unique encryption parameters
Delta compression is automatically disabled for encrypted channels since encrypted payloads have no similarity between messages.
- Sensitive financial data
- Healthcare information
- Legal communications
- Personal messages
Cache Channels
Cache channels store the last published message and deliver it immediately to new subscribers. Perfect for maintaining stateful data. Naming: Add#cache-{ttl} suffix where TTL is in seconds
- Persistent data - Last message stored with TTL
- Instant delivery - New subscribers get cached data immediately
- Auto-expiration - Cache cleared after TTL
- Works with any channel type (public, private, presence)
- Dashboard initial state
- Current game state
- Latest sensor readings
- Active configuration
Channel Lifecycle
Subscription Flow
Message Delivery
When a message is published to a channel:- HTTP API receives event via POST request
- Authentication validates request signature
- Adapter broadcast distributes to all server instances (if using Redis/NATS)
- Local delivery each instance delivers to its local subscribers
- Tag filtering (optional) filters messages based on subscriber filters
- Delta compression (optional) sends only message deltas
- WebSocket send serializes and sends to client
Unsubscribe Flow
Presence notification
If this was the user’s last connection, server broadcasts
pusher_internal:member_removed.Channel Limits
Sockudo enforces limits to prevent abuse: Per application (configurable):- Maximum concurrent connections
- Maximum messages per second
- Maximum channels per connection
- Maximum message size
- Channel name: 200 characters max
- Event name: 200 characters max
- Allowed characters:
a-zA-Z0-9_\-=@,.;
Multi-Channel Operations
Broadcasting to Multiple Channels
Publish the same event to multiple channels in one API call:Batch Events
Send multiple different events in one request:Presence Member Info
When subscribing to presence channels, you can attach custom user information:User info is visible to all channel members. Don’t include sensitive data.
Channel Best Practices
Choose the right channel type
Choose the right channel type
- Use public for truly public data
- Use private for user-specific or sensitive data
- Use presence when you need to track online users
- Use encrypted for highly sensitive data
- Use cache for stateful data that needs persistence
Design efficient channel structures
Design efficient channel structures
- Use hierarchical names:
game:123:chatinstead ofgame_123_chat - Include IDs in names:
user-{user_id}for per-user channels - Namespace by feature:
notifications.*,chat.* - Keep channel names short and consistent
Manage channel scale
Manage channel scale
- Limit subscriptions per connection (e.g., max 100 channels)
- Use channel patterns instead of per-item channels when possible
- Implement pagination for large member lists
- Monitor channel count and subscriber distribution
Handle connection failures gracefully
Handle connection failures gracefully
- Implement automatic reconnection with exponential backoff
- Re-subscribe to channels after reconnection
- Use cache channels to get current state after reconnection
- Handle duplicate member_added events on presence channels
Next Steps
Authentication
Learn how to authenticate private and presence channels
Tag Filtering
Reduce bandwidth with server-side message filtering
Delta Compression
Send only message differences for bandwidth savings
Client Libraries
Connect with Pusher-compatible SDKs