Media Server (SFU)
কখন LiveKit মিডিয়া সার্ভার লাগে, VPS-এ ইনস্টল, কী ও TURN সহ livekit.yaml, Caddy দিয়ে HTTPS, ফায়ারওয়াল পোর্ট, প্লাগিন সেটিং, ফলব্যাক মোড, আর সাইটে কী থেকে যায়।
The Media Server (SFU) plugin sends the audio and video of every meeting through a LiveKit server instead of from browser to browser. It is free and new in version 1.1.0.
1. Why and when
By default AIOMeeting uses mesh. Every browser sends its video to every other browser. That needs no server and runs on cPanel, but each person uploads one copy of their video for every other person. It suits about a dozen people on video. See Slow connections and quality.
An SFU (selective forwarding unit) is a server that receives one copy from each person and forwards the right size to everyone else. Then:
- Rooms of 50, 100 or 300 people work.
- A person on a weak connection uploads one stream only.
- Each viewer gets the video size their connection can take.
- LiveKit has TURN built in, so people behind strict firewalls connect.
You need a second server for this. cPanel shared hosting cannot run LiveKit. Use a small VPS. If your rooms stay small, leave the plugin off.
2. What stays on your site
Only the path of audio and video changes. These stay on your AIOMeeting site, exactly as before:
- The rooms, the roster, the waiting room and the host controls.
- Chat, reactions and signals.
- Breakout rooms. Each breakout room becomes its own room on the media server, so people in different rooms do not hear each other.
- Recordings. They still happen in the browser and upload to your site.
- Packages, limits and billing. The package limit on participants still applies.
The media server only sees a name, a role and the audio and video. Webinar attendees (viewers) get a token that lets them watch but not publish.
3. Set up LiveKit on a VPS
You need a VPS with a public IP address, a domain name such as sfu.example.com pointing at it, and root access. A VPS with 1 vCPU and 1 GB of memory is enough to try it and for a few small rooms. Bandwidth is the real limit. A room of 100 people receives many streams, so choose a plan with plenty of traffic and keep listeners' cameras off.
3.1 Install
On Linux, run the installer from LiveKit:
curl -sSL https://get.livekit.io | bash
Or run the Docker image livekit/livekit-server.
To try it quickly, run livekit-server --dev. It starts a test server with the key devkey and the secret secret. Do not use it for real meetings.
3.2 Make the keys
livekit-server generate-keys
It prints an API key and an API secret. Keep both. You will type them in the plugin.
3.3 The file livekit.yaml
Save this as /etc/livekit.yaml and put your own values in:
port: 7880
rtc:
tcp_port: 7881
port_range_start: 50000
port_range_end: 60000
use_external_ip: true
keys:
YOUR_API_KEY: YOUR_API_SECRET
turn:
enabled: true
domain: turn.example.com
udp_port: 3478
portis where the WebSocket listens. Caddy will forward to it.rtc.tcp_portand the port range carry the media.use_external_ip: truelets LiveKit find the public address of the VPS.keysholds the pair from step 3.2, written askey: secret.turnswitches on the built-in TURN. It helps people behind strict firewalls. A TURN service on port 5349 with TLS also needstls_port: 5349and a certificate (cert_fileandkey_file) for the TURN domain. If you are not sure, start with UDP 3478 and add TLS later.
Start the server and keep it running. With systemd, make a unit that runs livekit-server --config /etc/livekit.yaml and set it to restart on failure.
3.4 HTTPS with Caddy
Browsers allow a secure WebSocket (wss://) only. Use Caddy, which gets a free certificate by itself. In /etc/caddy/Caddyfile:
sfu.example.com {
reverse_proxy localhost:7880
}
Reload Caddy. Open https://sfu.example.com in a browser. A short "OK" from LiveKit means the proxy works. The address for the plugin is wss://sfu.example.com.
3.5 The firewall
Open these ports on the VPS and in the cloud firewall of your provider:
| Port | Why |
|---|---|
| TCP 80 and 443 | Caddy: the certificate and the secure WebSocket |
| TCP 7881 | Media over TCP when UDP is blocked |
| UDP 50000-60000 | The media itself. This is the most important rule. |
| UDP 3478 | TURN |
| TCP 5349 | TURN with TLS, only if you set it up |
With ufw on Ubuntu:
ufw allow 80,443/tcp
ufw allow 7881/tcp
ufw allow 50000:60000/udp
ufw allow 3478/udp
4. The plugin settings
- Open Settings, Plugins and activate Media Server (SFU).
- Open Plugins, Media Server (SFU) in the admin menu.
- Fill in the form and press Save.
| Field | Default | What it does |
|---|---|---|
| Mode | Off (mesh) | Off keeps mesh. On (media server) sends every meeting through the server. On, fall back to mesh tries the server and uses mesh if it does not answer. |
| Server address | empty | The WebSocket address, for example wss://sfu.example.com. For a test on the same machine, ws://127.0.0.1:7880. |
| API key | empty | The key from livekit.yaml. In --dev mode it is devkey. |
| API secret | empty | The secret from livekit.yaml. It is stored encrypted. Leave the field empty to keep the stored secret. |
| Token lifetime (minutes) | 360 | How long a join token is valid. A browser asks for a fresh one when it reconnects. |
| Room size with the server | 300 | The most people in one meeting while the server is on. The package limit still applies, so the smaller number wins. 0 means the package limit only. |
| Simulcast | Yes | Each camera sends three sizes so the server can give each person the one they can take. |
| Video width | 1280 x 720 | The largest size a camera sends: 640 x 360, 960 x 540, 1280 x 720 or 1920 x 1080. |
| Largest video bitrate (kbps) | 1500 | The ceiling for one video stream. Minimum 200. |
| Client library | jsDelivr address of livekit-client | The LiveKit browser library. It is loaded only when the server is on. Keep its version in step with the server. You can host the file yourself and put its address here. |
When the settings are complete, a green notice at the top says the media server is on and that tokens sign correctly. It shows the mode and the address.
5. Test it
- Set the mode to On, fall back to mesh.
- Open a meeting on two devices.
- A short message says Connected through the media server.
- Open the Connection panel in the room. It names the media server as the path.
6. Fallback mode
- In On, fall back to mesh, if the server does not answer, the room says "The media server did not answer; using direct connections instead" and reloads that browser tab in mesh mode. Other people who connected to the server stay on it.
- In On (media server) there is no fallback. The room says it cannot reach the media server, and audio and video do not work until it answers.
- Use the fallback mode while you test. Use On when you want to be sure that nobody ever uses mesh.
- To go back to mesh for everyone, set the mode to Off. New meetings use mesh at once.
7. Troubleshooting
| Problem | Fix |
|---|---|
| The room falls back to mesh at once | Check the address. It must start with wss:// on a live site and match the Caddy domain. Open it in a browser to see if it answers. |
| "Cannot reach the media server" | The server is down, the DNS name is wrong, or port 443 is blocked. Check the service with systemctl status. |
| Connects, but no video or sound | The UDP range 50000-60000 or TCP 7881 is closed. Open them in the VPS firewall and in the provider's panel. Check use_external_ip: true. |
| Works at home but not from some offices | Turn TURN on in livekit.yaml and open UDP 3478. Add TLS TURN on 5349 for the strictest networks. |
| "invalid token" in the browser console | The API key or secret in the plugin does not match livekit.yaml. Type them again. |
| The page asks for a camera but the library does not load | The client library address is wrong or blocked. Check it under Advanced. |
| Video is choppy in a big room | Lower Largest video bitrate and Video width. Ask listeners to turn their cameras off. Check the VPS network and CPU. |