{"slug": "slyber-sfu-server-webrtc-media-router-for-calls-webinars-and-ai-bots", "title": "Slyber SFU Server - WebRTC Media Router for Calls, Webinars, and AI Bots", "summary": "A developer built Slyber SFU Server, an open-source WebRTC Selective Forwarding Unit written in Go on Pion WebRTC v4, distributed as a single static binary with no external dependencies. The server multiplexes all media over one port (4443) using ICEUDPMux and ICETCPMux, and adds Simulcast and VP9 SVC layer routing, WHIP/WHEP broadcasting, SFrame end-to-end encryption, HMAC inter-node cascading, and a full-duplex /ai/ws WebSocket gateway for connecting AI voice agents such as Gemini Live or the OpenAI Realtime API without a separate WebRTC stack. It also includes a FastSwapRouletteTrack path for 1v1 roulette-style switching that rewrites sequence numbers and timestamps to avoid SDP renegotiation and black-screen gaps.", "body_md": "Hey devs! 👋\n\nIn this overview, I will explain in simple terms what **Slyber SFU Server** is, why it is needed, how it works under the hood, and what problems it solves out of the box.\n\nHigh performance WebRTC Selective Forwarding Unit (SFU) built with Go and Pion WebRTC v4, featuring a single port ICE-Lite UDP/TCP multiplexer, Simulcast & VP9 SVC routing, WHIP/WHEP broadcasting, SFrame End to End Encryption (E2EE), inter-node HMAC cascading, and a full duplex AI voice WebSocket pipe.\n\n`sync.Pool` packet buffers (`SlyberPacket`), atomic reference counting, in place RFC 3550/8285 header parsing, and copy on write subscriber snapshots.`ICEUDPMux`), RFC 4571 ICE-TCP (` ICETCPMux`), DTLS-SRTP encryption, TWCC sender feedback, and NACK generation on a single media port (`4443` by default).`ClampSpatialLayer`), per layer NACK…\n**Slyber SFU Server** is a real time selective audio, video, and data routing server written in Go. It is distributed as a single static binary with zero external dependencies and handles group video conferences, 1 on 1 calls, live streaming (for example, from OBS Studio), and voice conversations with AI agents. It can also be deployed via Docker.\n\nWhen two people make a direct call in a browser, their devices exchange video and audio without intermediaries. However, as soon as 10 people join a room, peer to peer connections break down: each participant's browser is forced to compress and upload **9 separate copies** of their video and audio one for every other participant. Phones quickly overheat, and batteries drain rapidly.\n\nAn **SFU (Selective Forwarding Unit)** acts like an automated mail sorting center:\n\nI designed the server so that it can be deployed on a clean Linux machine in one minute without manually editing configuration files. Here is what the system consists of:\n\n`:4443` for Both UDP and TCP\nIn Slyber SFU Server, all media traffic across all rooms flows through a single port `4443`. At the ingress, it uses `ICEUDPMux` and `ICETCPMux` multiplexers (RFC 4571 standard):\n\n`8090/TCP` port handles WebSocket signaling (`/ws`), broadcast gateways, and telemetry metrics.` q`, `h`, `f` layers for example, 270p, 540p, and 1080p) and the scalable `SubscriberBWE` bandwidth controller continuously monitors reports from each viewer (`TWCC`, `REMB`, `RTCP Receiver Report`). As soon as a specific viewer's bandwidth drops or packet loss increases, the server smoothly switches In a 30 person group call, there is no point in transmitting video from all 28 silent participants. The server reads the audio volume level from the unencrypted **RFC 6464** (`ssrc-audio-level`) packet header without decrypting the voice payload itself. The `EnforceLastNVideo` mechanism automatically pauses cameras of silent participants and instantly resumes their video starting with a keyframe as soon as they begin speaking.\n\nIn standard WebRTC, switching conversation partners requires re-exchanging SDP Offer/Answer messages, which leaves the viewer staring at a black screen for 1–2 seconds.\n\nFor the `roulette_1v1` profile, Slyber SFU implements the `FastSwapRouletteTrack` method. Candidate streams are pre-warmed at ingress, and switching happens simply by flipping an internal pointer. The `SeqTimestampRewriter` module aligns packet sequence numbers (`SequenceNumber`) and timestamps of the new partner on the fly so the viewer's browser perceives the stream as continuous with zero gaps and zero SDP renegotiation.\n\n`/ai/ws` Gateway for AI Voice Agents\nTo add a voice bot powered by Gemini Live or the OpenAI Realtime API to a call, you do not need to run a heavy WebRTC stack in Python or Node.js. Simply connect your AI backend to the built-in `/ai/ws` WebSocket gateway:\n\n`mode=mux`):` ai_vad_barge_in` event to your backend.`WHIP/WHEP`), `MoQ`, and Server Cascading\n`POST /whip/{room}/{track}` and distribute to viewers via `POST /whep/{room}/{track}` in a single HTTP request with `ETag`-based stream owner protection.` moqt-draft-22` objects (`/moq/{room}/{track}`).`/cascade/`):` HMAC-SHA256-128` cryptographic signature on every packet and built-in SSRF protection against attacks on local subnets.`HS256 JWT` tokens (with granular permissions like `can_publish`, `can_subscribe`, `max_spatial_layer`), a pooled `Redis` connection (instant access revocation upon deleting the `slyber:session:<token>` key), or stateless `HMAC-SHA1` tokens.`REQUIRE_E2EE=true` is enabled, the server validates `TrafficPolice` shaper enforces bitrate limits per track and per session.\n| Subsystem | Slyber SFU Server Implementation | \n|---|---|\n| **Stack & Build** | Go + `pion/webrtc/v4` ; single static binary for Linux and macOS (`amd64` ,`arm64` ) | \n| **Network Transport** | `ICE-Lite` mode; single port`4443` for UDP (`ICEUDPMux` ) and TCP (`RFC 4571 ICETCPMux` ); HTTP/WS gateway on`8090` ; auto-tuning of OS socket buffers up to 8 MB | \n| **Codecs** | Video: `VP9` (including SVC),`AV1` ,`H264` ,`VP8` ; Audio:`Opus` 48 kHz stereo with Inband FEC | \n| **Room Profiles** | 5 ready-to-use modes: `conference` ,`roulette_1v1` ,`broadcast` ,`gaming` ,`ai_voice` (up to 5,000 active rooms per node) | \n| **Quality & QoS** | Simulcast (3 layers), VP9 SVC, `SubscriberBWE` (TWCC/REMB/RR), per-layer NACK ring buffers (512 packets), per-layer`PLICoalescer` (500 ms),`Last-N` via RFC 6464 | \n| **Gateways & Clustering** | `WHIP/WHEP` , full-duplex`/ai/ws` (`mode=mux` , 20 ms pacer, VAD Barge-In),`MoQ` (`moqt-draft-22` ), UDP`/cascade/` with`HMAC-SHA256-128` | \n| **Security** | `jwt` ,`redis` , and`secret` auth modes; dedicated`NODE_SECRET` key;`RFC 9605 SFrame` E2EE + MLS;`TrafficPolice` rate limiter | \n| **Monitoring** | JSON telemetry at `/inspector/stats` , Prometheus`/metrics` exporter, and built-in`slyber-sfu doctor` CLI diagnostics | \n\nInstall the server on a clean Linux host in one command the script downloads the binary, verifies the `SHA256SUMS` checksum, tunes kernel network buffers, generates secret keys in `/opt/slyber_sfu/.env`, opens port `4443`, and starts the `systemd` service:\n\n```\ncurl -fsSL [https://raw.githubusercontent.com/slyber-app/slyber-sfu-server/main/install.sh](https://raw.githubusercontent.com/slyber-app/slyber-sfu-server/main/install.sh) | sudo bash\n```\n\nOr run it in Docker from the official GitHub Container Registry:\n\n```\ndocker pull ghcr.io/slyber-app/slyber-sfu-server:latest\ndocker rm -f slyber-sfu-server 2>/dev/null || true\n\nPUBLIC_IP=$(curl -fsSL4 --max-time 2 api.ipify.org 2>/dev/null || echo 127.0.0.1)\nJWT_SECRET=$(head -c 24 /dev/urandom | od -An -tx1 | tr -d ' \\n')\nNODE_SECRET=$(head -c 24 /dev/urandom | od -An -tx1 | tr -d ' \\n')\n\ndocker run -d \\\n  --name slyber-sfu-server \\\n  --restart unless-stopped \\\n  --network host \\\n  -e SFU_ENV=\"production\" \\\n  -e PUBLIC_IP=\"${PUBLIC_IP}\" \\\n  -e SFU_UDP_PORT=\"4443\" \\\n  -e SFU_TCP_PORT=\"4443\" \\\n  -e SFU_HTTP_PORT=\"8090\" \\\n  -e AUTH_MODE=\"jwt\" \\\n  -e JWT_SECRET=\"${JWT_SECRET}\" \\\n  -e NODE_SECRET=\"${NODE_SECRET}\" \\\n  ghcr.io/slyber-app/slyber-sfu-server:latest && \\\n  sleep 1 && \\\n  docker exec slyber-sfu-server slyber_sfu doctor && \\\n  echo \"Public IP  : ${PUBLIC_IP}\" && \\\n  echo \"JWT Secret : ${JWT_SECRET}\" && \\\n  echo \"Node Secret: ${NODE_SECRET}\" && \\\n  echo \"Test Token : $(curl -fsS -H \"X-Slyber-Node-Secret: ${NODE_SECRET}\" \"http://127.0.0.1:8090/auth/token?room=test-room&user=user-1\")\"\n```\n\nVerify the health of a running node using the built in self \n\ndiagnostics command:\n\n``` bash\n$ slyber-sfu doctor\n================================================================\n SLYBER SFU DOCTOR | Version: v1.0.0 | Node: slyber-sfu-01\n================================================================\n [OK] Environment       : production\n [OK] Public IP & Realm : 89.111.175.67 (slyber.com)\n [OK] Pion ICE Mux      : UDP :4443 | TCP :4443 (ICE-TCP=true) | HTTP :8090\n [OK] Auth & Security   : jwt (E2EE=true, External TURN=1)\n [OK] All Slyber SFU self-diagnostics passed.\n================================================================\n```\n\n[GitHub Repository](https://github.com/slyber-app/slyber-sfu-server)\n\n[Official Documentation](https://slyber.com/docs/slyber-sfu-server) \n\n[Technical Case Study](https://erkin-khidirov.com/cases/slyber-sfu-server)", "url": "https://wpnews.pro/news/slyber-sfu-server-webrtc-media-router-for-calls-webinars-and-ai-bots", "canonical_source": "https://dev.to/erkin_khidirov_e1a1d8dc51/slyber-sfu-server-webrtc-media-router-for-calls-webinars-and-ai-bots-k9g", "published_at": "2026-11-15 05:44:40+00:00", "updated_at": "2026-11-15 05:51:32.547432+00:00", "lang": "en", "topics": ["ai-agents", "ai-tools", "developer-tools", "ai-infrastructure"], "entities": ["Slyber SFU Server", "Pion WebRTC", "Go", "Gemini Live", "OpenAI Realtime API", "OBS Studio", "Docker"], "also_reported_by": [], "alternates": {"html": "https://wpnews.pro/news/slyber-sfu-server-webrtc-media-router-for-calls-webinars-and-ai-bots", "markdown": "https://wpnews.pro/news/slyber-sfu-server-webrtc-media-router-for-calls-webinars-and-ai-bots.md", "text": "https://wpnews.pro/news/slyber-sfu-server-webrtc-media-router-for-calls-webinars-and-ai-bots.txt", "jsonld": "https://wpnews.pro/news/slyber-sfu-server-webrtc-media-router-for-calls-webinars-and-ai-bots.jsonld"}}