Sockudo Documentation

Build, operate, and extend Sockudo: the self-hosted Rust realtime server with Pusher compatibility, Protocol V2, clustered fanout, recovery, history, push, and official SDKs.

5 min read
View .mdEdit on GitHub

Sockudo is a self-hosted realtime server written in Rust. It speaks the Pusher Channels protocol, so existing Pusher clients and server libraries work against it, and it adds a native protocol for durable history, connection recovery, mutable messages, and other features Pusher does not offer. Start here whether you are replacing Pusher, building a new realtime product, or evaluating Sockudo for a clustered production deployment.

Sockudo documentation

Ship Pusher-compatible realtime now. Add durability when you need it.

Sockudo keeps the Pusher-shaped WebSocket and HTTP API familiar while giving teams a native Protocol V2 path for recovery, history, mutable messages, annotations, push and horizontal fanout.

Drop-in surface
Protocol V1
Native layer
Protocol V2
Runtime
Rust + Tokio
Operations
Cluster ready

Key terms

These terms appear on every page of the documentation.

TermMeaning
AppA tenant on the server. Each app has an id, a public key that clients use to connect, and a secret that only your backend holds and uses to sign requests.
ChannelA named stream that clients subscribe to. The name prefix (private-, presence-, private-encrypted-) decides whether a subscription needs your backend’s approval.
EventA named message published to one or more channels, such as order.created.
Protocol V1The Pusher-compatible wire protocol. It is the default, so pusher-js, Laravel Echo, and Pusher server SDKs keep working unchanged.
Protocol V2Sockudo’s native wire protocol. Clients opt in, and V2 adds message_id, serial, and stream_id metadata plus recovery, rewind, deltas, filters, and more.
AdapterThe layer that relays broadcasts and presence between Sockudo nodes. The local adapter serves a single node; Redis, NATS, Kafka, and others connect a cluster.
App managerWhere app records live: inline in the config file (memory) or in a database such as PostgreSQL or MySQL.

Production topology

Sockudo sits between realtime clients and your trusted backends. Clients hold long-lived WebSocket connections and subscribe to public, private, presence, or encrypted channels. Backends never hold a socket; they call the HTTP API, usually through a server SDK, to publish events, sign channel auth, mutate V2 messages, manage push devices, and inspect operational state.

  • WebSocket ingress: client connect, subscribe, auth, presence, and realtime delivery.
  • HTTP control plane: trusted publishes, channel state, history reads, message mutations, annotations, and push workflows.
  • Horizontal fanout: Redis, NATS, Kafka, RabbitMQ, Pulsar, Google Pub/Sub, Iggy, or another configured adapter.

Start with the in-memory local profile, then move app records, caches, queues, adapters, history, and push status into production backends as the deployment grows. Each move is a configuration change, not a code change in your clients.

interactive 3D
Protocol V1 compatibility and Protocol V2 durability run through the same server edge: publish once, fan out across nodes, deliver to every socket, and recover gaps from durable history.

Follow these steps in order the first time. Each one builds on the previous page.

  1. Run a local Sockudo server from Installation.
  2. Publish and receive your first event from First connection.
  3. Add private and presence channel auth from Authentication.
  4. Choose Protocol V1 or V2 from Compatibility.
  5. Wire your client from Realtime Clients and your backend from Server SDKs.
  6. Follow the Deployment guide, then harden the runtime with Scaling, Security, and Observability.

Developer quick loops

The snippets below form one complete loop: start a server, subscribe, publish, and confirm the event arrives. They all use the same local development app:

SettingValue
App IDapp-id
App keyapp-key
App secretapp-secret
WebSocket and HTTP API127.0.0.1:6001
Prometheus metrics127.0.0.1:9601

Run Sockudo and check health

Start the published container image with the development app defined through environment variables:

Terminal window
docker run --rm --name sockudo \
-p 6001:6001 -p 9601:9601 \
-e SOCKUDO_DEFAULT_APP_ID=app-id \
-e SOCKUDO_DEFAULT_APP_KEY=app-key \
-e SOCKUDO_DEFAULT_APP_SECRET=app-secret \
ghcr.io/sockudo/sockudo:latest

In a second terminal, check the health probe and the metrics endpoint:

Terminal window
curl -s http://127.0.0.1:6001/up
curl -s http://127.0.0.1:9601/metrics | head -n 3

/up prints OK when the server is healthy and at least one app is configured. The metrics endpoint returns Prometheus text whose series start with sockudo_.

Use cargo run --release -p sockudo instead when you want to validate a source build or a specific feature set. Installation covers every install path.

Subscribe from a client

client.ts
import Sockudo from "@sockudo/client";
const client = new Sockudo("app-key", {
wsHost: "127.0.0.1",
wsPort: 6001,
forceTLS: false,
enabledTransports: ["ws"],
protocolVersion: 2,
});
client.subscribe("orders").bind("order.created", (payload) => {
console.log("received", payload);
});

Set protocolVersion: 2 when the client needs Sockudo-native recovery, rewind, message IDs, tags, deltas, annotations, or mutable messages. Without it, the client connects with Protocol V1. Leave existing Pusher-compatible clients on V1 until you are ready to adopt V2 behavior.

Publish from a trusted backend

publish.ts
import Sockudo from "sockudo";
const sockudo = new Sockudo({
appId: "app-id",
key: "app-key",
secret: "app-secret",
host: "127.0.0.1",
port: 6001,
useTLS: false,
});
await sockudo.trigger(
"orders",
"order.created",
{ id: "ord_123", total: 4200 },
{ idempotency_key: "order-created-ord_123" },
);

The client from the previous step logs received { id: 'ord_123', total: 4200 }. Server SDKs sign requests, format payloads, and hide HMAC details. Use raw HTTP only when you are implementing or debugging an SDK; First connection shows a signed curl request.

Turn local config into a production shape

config/config.toml
port = 6001
host = "0.0.0.0"
debug = false
[app_manager]
driver = "pgsql"
[adapter]
driver = "redis"
[cache]
driver = "redis"
[queue]
driver = "redis"
[metrics]
enabled = true
port = 9601
SectionWhat it controls
[app_manager]Where app IDs, keys, secrets, and policies are stored. postgres reads them from PostgreSQL instead of the config file.
[adapter]How nodes share broadcasts and presence. redis lets every node deliver events published on any other node.
[cache]Shared short-lived state such as idempotency keys and capability-token revocations.
[queue]Background work such as webhook delivery.
[metrics]The Prometheus endpoint, served on its own port.

The important move is not a single backend choice. It is separating connection fanout, app records, cache state, queue work, durable history, push status, and metrics so each subsystem can fail, scale, and be observed independently.

Local baseline

Running the binary from a repository checkout loads config/config.toml, which defines the same development app inline:

config/config.toml
port = 6001
host = "0.0.0.0"
[app_manager]
driver = "memory"
[[app_manager.array.apps]]
id = "app-id"
key = "app-key"
secret = "app-secret"
enabled = true

For production, replace every example credential, enable TLS at the edge, use managed app storage, and keep app secrets only on trusted servers.

Production readiness checklist

  • Compatibility: decide which clients stay on Protocol V1 and which channels may use Protocol V2 features.
  • Authentication: keep app secrets server-side, sign private and presence auth responses, and reject stale HTTP signatures.
  • Fanout: choose an adapter, configure sticky sessions when required, and test cross-node broadcast delivery before launch.
  • Durability: enable history, recovery, version storage, annotations, and push status only for channels that need those contracts.
  • Idempotency: attach stable keys to retried publishes, message mutations, push requests, and backend workflows.
  • Observability: scrape /metrics, alert on connection churn, publish failures, adapter errors, webhook retries, push provider outcomes, and recovery failures.
  • Operations: document feature flags, runtime config, secret rotation, rollout order, and rollback behavior for every backend dependency.

Next steps