📖 How it works

## Request flow

Every request you make to the public URL travels through this path:

    Browser
      │
      ▼  HTTPS
    rustunnel-server  (your VPS)
      │  WebSocket + TLS
      ▼  yamux stream
    rustunnel client  (your laptop / dev machine)
      │  plain TCP
      ▼
    this demo server  :3000

## Two WebSocket connections

The client maintains two persistent connections to the server:

Control plane
JSON frames
auth · registration · heartbeat
Data plane
Binary yamux
all proxied connections multiplexed

## Protocol frames

Key control frames exchanged at startup:

Frame | Direction | Purpose
--- | --- | ---
Auth | → server | Send token + client version
AuthOk | ← server | Receive session_id
RegisterTunnel | → server | Request subdomain / port
TunnelRegistered | ← server | Receive public URL
NewConnection | ← server | Incoming request notification
Ping / Pong | ↔ | Heartbeat (every 30 s)

## Reconnection

If the connection drops, the client reconnects automatically with exponential backoff: 1 s → 2 s → 4 s … 60 s with ±20% jitter. Auth errors are the only fatal case — everything else retries.

← Home Live stats →