Skip to main content

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
// Client subscribes
const channel = pusher.subscribe('my-channel');
channel.bind('my-event', (data) => {
  console.log('Received:', data);
});
Use cases:
  • Live sports scores
  • Stock ticker updates
  • Public notifications
  • News feeds
Any client with your app key can subscribe to public channels. Don’t send sensitive data on public channels.

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 with private-
// Client subscribes (library handles auth automatically)
const channel = pusher.subscribe('private-user-123');
The client library will automatically request an authentication token from your server’s auth endpoint:
// Configure auth endpoint
const pusher = new Pusher(appKey, {
  cluster: 'mt1',
  authEndpoint: '/pusher/auth'
});
Features:
  • Authentication required - Server validates subscription requests
  • Client events - Clients can trigger events to other channel members
  • Selective access - Control who can subscribe per channel
Use cases:
  • 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 with presence-
// Client subscribes with user info
const channel = pusher.subscribe('presence-chat-room');

// Access member list
channel.bind('pusher:subscription_succeeded', (members) => {
  members.each((member) => {
    console.log(member.id, member.info);
  });
});

// Member joins
channel.bind('pusher:member_added', (member) => {
  console.log('Joined:', member.id, member.info);
});

// Member leaves
channel.bind('pusher:member_removed', (member) => {
  console.log('Left:', member.id);
});
Features:
  • 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
Member tracking:
  • Each unique user_id appears once in the member list
  • Multiple connections from the same user count as one member
  • Member is removed only when their last connection leaves
Use cases:
  • 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 with private-encrypted-
// Client subscribes
const channel = pusher.subscribe('private-encrypted-chat');
channel.bind('my-event', (data) => {
  console.log('Decrypted:', data);
});
Features:
  • 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.
Use cases:
  • 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
// Channel with 1-hour cache
const channel = pusher.subscribe('ticker#cache-3600');

// Server publishes
fetch('/apps/my-app/events', {
  method: 'POST',
  body: JSON.stringify({
    channel: 'ticker#cache-3600',
    name: 'price-update',
    data: {price: 42.50}
  })
});
Features:
  • 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)
Use cases:
  • Dashboard initial state
  • Current game state
  • Latest sensor readings
  • Active configuration

Channel Lifecycle

Subscription Flow

1

Client subscribes

Client sends pusher:subscribe event with channel name.
2

Authentication

For private/presence/encrypted channels, server validates authentication signature.
3

Channel join

Server adds client to channel’s subscriber list.
4

Confirmation

Server sends pusher_internal:subscription_succeeded event.
5

Presence notification

Server broadcasts pusher_internal:member_added to other channel members.

Message Delivery

When a message is published to a channel:
  1. HTTP API receives event via POST request
  2. Authentication validates request signature
  3. Adapter broadcast distributes to all server instances (if using Redis/NATS)
  4. Local delivery each instance delivers to its local subscribers
  5. Tag filtering (optional) filters messages based on subscriber filters
  6. Delta compression (optional) sends only message deltas
  7. WebSocket send serializes and sends to client

Unsubscribe Flow

1

Client unsubscribes

Client sends pusher:unsubscribe event.
2

Channel leave

Server removes client from subscriber list.
3

Presence notification

If this was the user’s last connection, server broadcasts pusher_internal:member_removed.
4

Channel cleanup

If no subscribers remain, channel is removed from memory.

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
Protocol limits:
  • Channel name: 200 characters max
  • Event name: 200 characters max
  • Allowed characters: a-zA-Z0-9_\-=@,.;
{
  "app_manager": {
    "array": {
      "apps": [{
        "id": "my-app",
        "max_connections": 1000,
        "max_message_size_kb": 10,
        "enabled": true
      }]
    }
  }
}

Multi-Channel Operations

Broadcasting to Multiple Channels

Publish the same event to multiple channels in one API call:
curl -X POST http://localhost:6001/apps/my-app/events \
  -H "Content-Type: application/json" \
  -d '{
    "channels": ["channel-1", "channel-2", "channel-3"],
    "name": "my-event",
    "data": "{\"message\": \"hello\"}"
  }'

Batch Events

Send multiple different events in one request:
curl -X POST http://localhost:6001/apps/my-app/batch_events \
  -H "Content-Type: application/json" \
  -d '{
    "batch": [
      {"channel": "ch1", "name": "event1", "data": "..."},
      {"channel": "ch2", "name": "event2", "data": "..."}
    ]
  }'

Presence Member Info

When subscribing to presence channels, you can attach custom user information:
// Server auth endpoint returns:
{
  "auth": "app_key:signature",
  "channel_data": {
    "user_id": "123",
    "user_info": {
      "name": "Alice",
      "avatar": "https://example.com/alice.jpg",
      "status": "online"
    }
  }
}
All channel members receive this information in presence events.
User info is visible to all channel members. Don’t include sensitive data.

Channel Best Practices

  • 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
  • Use hierarchical names: game:123:chat instead of game_123_chat
  • Include IDs in names: user-{user_id} for per-user channels
  • Namespace by feature: notifications.*, chat.*
  • Keep channel names short and consistent
  • 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
  • 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