Skip to content

LiveKit WebRTC SFU & TURN

FynnCloud includes a built-in RTC Broker (LiveKitService, /api/rtc/*) that connects apps declaring the rtc:rooms scope (such as FynnCloud Talk) to a LiveKit WebRTC SFU (livekit/livekit-server:v1.13.11).

The LiveKit master API secret stays strictly inside fynncloud-server—apps request short-lived HS256 participant tokens via /api/rtc/token and every room is automatically isolated per app under app_<appId>_<room>. When LiveKit is not configured (livekitUrl is empty), Talk automatically falls back to direct peer-to-peer WebRTC for 1:1 calls.

LiveKit’s WebSocket signaling runs over HTTPS (443/tcp → port 7880), while real-time audio/video media flows directly to the LiveKit host over UDP and TCP:

Port Protocol Purpose
443 TCP WebSocket signaling (wss://<domain>/livekit or custom wss://rtc.example.com) proxied to container :7880
7882 UDP Single-port WebRTC UDP media mux (primary media path; open directly on server firewall)
7881 TCP ICE-over-TCP fallback when corporate networks block UDP
3478 UDP LiveKit embedded TURN relay for restrictive 4G CGNAT / NAT64 / symmetric NAT clients
5349 (optional) TCP TURN/TLS (Kubernetes Helm chart when livekit.turn.domain + tlsSecretName are configured)

Option 1: FynnCloud AIO (Zero-Config Auto-Wiring)

Section titled “Option 1: FynnCloud AIO (Zero-Config Auto-Wiring)”

FynnCloud AIO manages fynncloud-livekit (livekit/livekit-server:v1.13.11, ~256 MB RAM) natively:

  • Pass --enable-livekit during fynncloud-aio setup, or
  • Toggle LiveKit on from Administration → System → Components (or run fynncloud-aio upgrade --enable-livekit).

When enabled, AIO automatically:

  1. Generates cryptographically random livekitApiKey and livekitApiSecret credentials in /data/secrets.json.
  2. Exposes WebSocket signaling at wss://<your-domain>/livekit (or a custom subdomain if components.livekit.domain is set in /data/stack.yaml).
  3. Publishes host ports 7882/udp, 7881/tcp, and 3478/udp (configurable in /data/stack.yaml under components.livekit).
  4. Writes livekitUrl, livekitInternalUrl (http://fynncloud-livekit:7880), livekitApiKey, and livekitApiSecret directly into FynnCloud’s encrypted AppSettings store.

Customizing AIO LiveKit Settings (/data/stack.yaml)

Section titled “Customizing AIO LiveKit Settings (/data/stack.yaml)”
components:
livekit:
enabled: true
domain: "" # empty => wss://<domain>/livekit; or e.g. "rtc.example.com"
udp_port: 7882
tcp_port: 7881
turn_enabled: true
turn_udp_port: 3478
external_ip: "" # empty => STUN auto-discovery; set explicitly behind 1:1 NAT

The official Helm chart deploys LiveKit with hostNetwork: true, strategy: Recreate, and terminationGracePeriodSeconds: 300 so UDP/TCP media bypasses Kubernetes CNI SNAT and active calls drain cleanly:

livekit:
enabled: true
hostNetwork: true
publicUrl: "" # defaults to wss://<httpRoute hostname>/livekit
rtc:
udpPort: 7882
tcpPort: 7881
useExternalIP: true
nodeIP: "" # optional static public IP override
turn:
enabled: true
udpPort: 3478
domain: "rtc.example.com"
tlsPort: 5349
tlsSecretName: "rtc-tls-cert" # enables TURN/TLS on 5349/tcp
auth:
existingSecret: "fynncloud-livekit-secret"
apiKeySecretKey: "livekit-api-key"
apiSecretSecretKey: "livekit-api-secret"

Create the secret before installing:

Terminal window
kubectl -n fynncloud create secret generic fynncloud-livekit-secret \
--from-literal=livekit-api-key="APIfynncloud" \
--from-literal=livekit-api-secret="$(openssl rand -hex 32)"

Option 3: Manual / External LiveKit Server

Section titled “Option 3: Manual / External LiveKit Server”

If you operate LiveKit Cloud or a standalone self-hosted LiveKit instance, configure the four .rtc dynamic AppSettings either in Administration → Settings → Real-Time Media (LiveKit) or via environment variables:

Setting Key Environment Variable Visibility Example
livekitUrl LIVEKIT_URL (alias RTC_LIVEKIT_URL) internal wss://rtc.example.com or wss://cloud.example.com/livekit
livekitInternalUrl LIVEKIT_INTERNAL_URL (alias RTC_LIVEKIT_INTERNAL_URL) internal http://fynncloud-livekit:7880 (optional; avoids hairpinning for Twirp moderation)
livekitApiKey LIVEKIT_API_KEY (alias RTC_LIVEKIT_API_KEY) internal APIfynncloud
livekitApiSecret LIVEKIT_API_SECRET (alias RTC_LIVEKIT_API_SECRET) secret 32+ char secret matching LiveKit keys:

Click Test LiveKit Connection in Administration → Settings (or call POST /api/rtc/test as an administrator). FynnCloud mints a 60-second server admin JWT and executes POST <twirpBaseURL>/twirp/livekit.RoomService/ListRooms:

  • Success: Returns {"success": true, "message": "Connected to LiveKit SFU (<publicURL>)"}.
  • Missing credentials: Also surfaced automatically as a livekitMisconfigured warning in Administration → System Health Alerts (GET /api/alerts).
  • Media connects on Wi-Fi but fails on mobile 4G/5G: Verify 7882/udp, 7881/tcp, and 3478/udp are open inbound on the host firewall and (if behind cloud NAT) set external_ip / nodeIP to the server’s public IPv4 address.