How Networking Works
Understanding how network traffic flows between a user's device, your reverse proxy, and the Spokes server makes it much easier to set up and troubleshoot your server.
Spokes uses a hybrid networking model: standard web and text chat traffic is routed through your reverse proxy over HTTPS, while real-time voice and video establish direct connections to your server that bypass the reverse proxy.
The Two Phases of a Connection
Section titled “The Two Phases of a Connection”When a user connects to your Spokes server and joins a voice channel, the connection happens in two phases.
Phase 1: Signaling (Web & WebSockets)
Section titled “Phase 1: Signaling (Web & WebSockets)”When you open Spokes, your browser or app makes standard HTTPS requests to your configured Server Public URL (e.g., https://spokes.yourdomain.com).
- Routing: This traffic hits your reverse proxy (such as Caddy, Nginx Proxy Manager, or a Cloudflare Tunnel).
- Upgrade: The proxy forwards the request to the Spokes container's Web UI port (internal port
8080) and upgrades the connection to a WebSocket (/_blazor). - Signaling: When you join a voice channel, Spokes generates a signed LiveKit join token and exchanges WebRTC signaling instructions with your client. No audio or video media is sent over this connection yet; the client and server are just negotiating how to exchange media packets.
Because this phase uses standard HTTPS and WebSockets, it works cleanly behind any reverse proxy, WAF, or Cloudflare Tunnel.
Phase 2: Media (Direct UDP / TCP Fallback)
Section titled “Phase 2: Media (Direct UDP / TCP Fallback)”During signaling, the client and the embedded LiveKit server negotiate a direct route for the real-time audio and video stream using WebRTC ICE (Interactive Connectivity Establishment).
- Public IP Discovery: On startup, the embedded LiveKit server discovers your router's public WAN IP address via STUN (
use_external_ip: true). Inside the container, Spokes also runs a background WAN IP monitor (wan_ip_monitor) that checks every 2 minutes if your ISP has changed your home IP address, and automatically restarts LiveKit if your public IP changes. - The Handshake: LiveKit tells your client which multiplexed UDP port (between
30000and30007) or TCP fallback port (7881) to send media to on your public IP. - Direct Connection: Your browser or mobile app sends encrypted WebRTC UDP packets directly to your router's public IP address, bypassing
spokes.yourdomain.comand your reverse proxy completely.
Why You Need 1-to-1 Port Forwarding
Section titled “Why You Need 1-to-1 Port Forwarding”This direct media connection is why port forwarding on your router is required for voice and video, even if you use a Cloudflare Tunnel for the Web UI.
When a client sends UDP media packets to your public IP on port 30000, those packets hit your hardware router. With port forwarding configured (30000-30007 UDP and 7881 TCP), your router forwards those packets straight into your Spokes Docker container.
If those ports are closed on your router or host firewall, or if they are not mapped 1-to-1 (for example, forwarding router port 30000 to container port 40000), the client will try to reach a port that does not match what LiveKit advertised during the handshake, and the voice connection will stay stuck on "Connecting...".
Advantages of This Architecture
Section titled “Advantages of This Architecture”This split approach gives you the best of both worlds:
- Security for Web Traffic: Your Web UI, login flow, and APIs sit safely behind your HTTPS reverse proxy or Cloudflare Tunnel.
- Low Latency for Voice and Video: Real-time voice, video, and screen sharing are sensitive to latency and jitter. Sending WebRTC UDP packets directly between clients and your server avoids the extra hops, bandwidth limits, and TCP head-of-line blocking of routing media through a reverse proxy.
