# Sockudo Documentation (https://sockudo.io/docs)
> Build, operate, and extend Sockudo: the self-hosted Rust realtime server with Pusher compatibility, Protocol V2, clustered fanout, recovery, history, push, and official SDKs.
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.
- [Install and verify](/docs/getting-started/installation): Run Sockudo locally, choose features, inspect health probes, and understand the default development app.
- [Connect the first loop](/docs/getting-started/first-connection): Subscribe from a client, publish from a trusted backend, add idempotency, and confirm metrics move.
- [Migrate from Pusher](/docs/getting-started/migration): Map pusher-js, Laravel Echo, Channels auth, event names, and publish calls onto Sockudo.
- [Design Protocol V2 streams](/docs/clients/protocol-v2): Use message IDs, serial continuity, rewind, deltas, tag filters, annotations, and recovery.
- [Deploy to production](/docs/deployment): Choose a topology, configure files and secrets, tune hosts, and deploy on VMs, containers, Kubernetes, or cloud platforms.
- [Reference the API](/docs/reference/http-endpoints): Find every server endpoint for publishing, channel state, history, mutations, annotations, push, and operations.
## Key terms
These terms appear on every page of the documentation.
| Term | Meaning |
| --- | --- |
| App | A 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. |
| Channel | A named stream that clients subscribe to. The name prefix (`private-`, `presence-`, `private-encrypted-`) decides whether a subscription needs your backend's approval. |
| Event | A named message published to one or more channels, such as `order.created`. |
| Protocol V1 | The Pusher-compatible wire protocol. It is the default, so `pusher-js`, Laravel Echo, and Pusher server SDKs keep working unchanged. |
| Protocol V2 | Sockudo's native wire protocol. Clients opt in, and V2 adds `message_id`, `serial`, and `stream_id` metadata plus recovery, rewind, deltas, filters, and more. |
| Adapter | The 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 manager | Where 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.
## Recommended path
Follow these steps in order the first time. Each one builds on the previous page.
1. Run a local Sockudo server from [Installation](/docs/getting-started/installation).
2. Publish and receive your first event from [First connection](/docs/getting-started/first-connection).
3. Add private and presence channel auth from [Authentication](/docs/getting-started/authentication).
4. Choose Protocol V1 or V2 from [Compatibility](/docs/reference/compatibility).
5. Wire your client from [Realtime Clients](/docs/clients) and your backend from [Server SDKs](/docs/server-sdks).
6. Follow the [Deployment guide](/docs/deployment), then harden the runtime with [Scaling](/docs/server/scaling), [Security](/docs/server/security), and [Observability](/docs/server/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:
| Setting | Value |
| --- | --- |
| App ID | `app-id` |
| App key | `app-key` |
| App secret | `app-secret` |
| WebSocket and HTTP API | `127.0.0.1:6001` |
| Prometheus metrics | `127.0.0.1:9601` |
These values are public examples. Replace every credential before exposing a server to a network, and keep the app secret on trusted servers only.
### Run Sockudo and check health
Start the published container image with the development app defined through environment variables:
```bash
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:
```bash
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](/docs/getting-started/installation) covers every install path.
### Subscribe from a client
```ts title="client.ts"
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
```ts title="publish.ts"
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](/docs/getting-started/first-connection#publish-over-raw-http) shows a signed `curl` request.
### Turn local config into a production shape
```toml title="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
```
| Section | What 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.
Drivers such as `redis` and `postgres` must be compiled into the binary. The prebuilt Linux binaries and container images include them; source builds need the matching `--features`. See [Feature flags](/docs/getting-started/installation#feature-flags).
## Local baseline
Running the binary from a repository checkout loads `config/config.toml`, which defines the same development app inline:
```toml title="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
- [Overview](/docs/getting-started/overview): The mental model: surfaces, protocols, channel types, and production shape.
- [Configuration reference](/docs/reference/configuration): Every config key, its default, and what it controls.
- [Troubleshooting](/docs/getting-started/troubleshooting): Diagnose connection, auth, publish, fanout, recovery, and push problems.