TURN Server Setup
Set up the TURN server that carries calls when players can't reach each other directly — with the wizard, or by hand.
Why a TURN server#
WebRTC first tries to connect players directly. That works on a LAN and between most home connections, but fails behind strict NATs, many mobile networks and company firewalls. A TURN server relays the media for exactly those players; everyone else still connects directly. NetCrafter Live uses coturn, the standard open-source TURN server, on a Linux machine you control — the machine running SmartFoxServer is a good choice.
Logins are time-limited (coturn's use-auth-secret): coturn and your zone extensions share one secret;
the extension hands each player a login valid for a limited time (24 h by default, renewed automatically). The secret never
leaves your server and never appears in a game build.
The TURN Server Wizard#
Open Tools → Pivec Labs → NetCrafter Pro → Live → TURN Server Wizard. Like NetCrafter Relay's wizard it never connects to your server itself: every step shows the exact command, you run it in your own terminal (your own SSH login) and paste the output back.
- Target — server address, SSH port and user.
- Pre-flight — log in, copy
install-coturn.shto the server (the wizard gives you thescpline), and check the OS (Ubuntu/Debian with systemd). - Detect — a read-only check: is coturn installed, does something else already use it, where is SmartFoxServer, what is the public IP.
- Install — one command installs/configures coturn, writes
NetCrafterLive.propertiesinto every SmartFoxServer extension folder and restarts SFS3. - Verify — tests a real time-limited login against coturn and checks SmartFoxServer's log for the Live "ready" line.
- Finish — saves the TURN host and ports into Live Server, so local Deploys write the same settings.
The secret
The wizard uses the shared secret from Live → Live Server (it creates one if there is none). It is stored in UserSettings/NetCrafterLiveServer.json — outside Assets/, so it is never part of a build or a package export. Use Check: is the secret anywhere under Assets/? in that tab if in doubt.
Sharing a server with NetCrafter Relay#
If the machine already runs coturn for something else — for example NetCrafter Relay, which uses fixed logins on port 3478 — the wizard detects it and installs a separate instance instead:
| Existing coturn (e.g. Relay) | NetCrafter Live instance | |
|---|---|---|
| Service | coturn | netcrafter-live |
| Config | /etc/turnserver.conf (untouched) | /etc/turnserver-netcrafter-live.conf |
| Port | 3478 | 3479 (TLS 5350 if used) |
| Relay ports | its own range | 50000–65535 |
| Logins | its own | time-limited (use-auth-secret) |
Nothing of the existing setup is changed, and each product can be updated or removed independently.
Installing by hand#
Live/ServerTools/install-coturn.sh is what the wizard runs; you can run it yourself:
scp install-coturn.sh root@your.server:~/
ssh root@your.server
sudo bash ~/install-coturn.sh --secret <64 hex chars> --turn-host your.server \
--sfs3-dir /opt/sfs3/SmartFoxServer3 -y && sudo systemctl restart sfs3| Option | Meaning |
|---|---|
--secret | Shared secret (required). Same value as live.turn.secret. |
--instance NAME | coturn = the system service; any other name = a separate instance. |
--port / --min-port / --max-port | Listening port (3478) and relay port range (49152–65535). |
--tls-port --tls-cert --tls-key | Optional TLS (e.g. 5349 with Let's Encrypt fullchain.pem / privkey.pem). Gets through networks that block UDP. |
--turn-host | Name or IP players connect to (default: detected public IP). |
--public-ip / --private-ip | For cloud servers behind 1:1 NAT, if detection is wrong. |
--sfs3-dir | Writes NetCrafterLive.properties into every extension folder that has a JAR. |
--max-call-size --max-viewers --ttl | Written to the properties file. |
--force | Allow replacing a /etc/turnserver.conf that has static user= logins. |
The script never enables a firewall. It hardens coturn (no CLI, no relaying to private/loopback addresses, quotas, TLS 1.2+ only) and prints NCL_* summary lines.
NetCrafterLive.properties#
Each zone extension reads NetCrafterLive.properties from its own extension folder when SmartFoxServer starts:
live.turn.secret=<same as coturn's static-auth-secret>
live.turn.host=turn.example.com
live.turn.port=3478
live.turn.tlsPort=0
live.turn.ttlSeconds=86400
live.maxCallSize=6
live.maxViewers=8- Local SFS3: Code → Server Code → Deploy writes it next to the JAR; Live → Live Server → Write NetCrafterLive.properties to the local SFS3 updates all Definitions at once.
- Remote SFS3: the wizard writes it, or use Copy command for a remote server in the Live Server tab and paste it into an SSH session.
- Restart SmartFoxServer after changing it. No file / no secret: Live still works for direct connections and warns once that TURN is unavailable.
Firewall#
| Port | Protocol | Why |
|---|---|---|
| 3478 (or 3479) | UDP + TCP | TURN/STUN |
| 5349 (or 5350) | TCP | TURN over TLS (only if enabled) |
| 49152–65535 (or 50000–65535) | UDP | relayed media |
| 9977 | TCP (+UDP) | SmartFoxServer (already open for your game) |
If ufw is active the script adds these rules; it never turns a firewall on. Your hosting provider's firewall (security group) must allow them too.
Windows development servers#
coturn has no native Windows build. For LAN tests you don't need TURN at all. To test the relay path on Windows, run coturn in
Docker (docker run -d --network host coturn/coturn -c /etc/turnserver.conf with a config like the one the script writes)
or inside WSL2 with the script itself.
Bandwidth#
In a call every player uploads one copy of their video per other player. NetCrafterLiveCall adapts automatically
(1 other player: 1500 kbps, 2–3: 800 kbps, 4–5: 500 kbps; 24 fps) unless you set maxVideoBitrateKbps.
| Players | Upload per player (video + voice) | Download per player |
|---|---|---|
| 2 | ≈ 1.5 Mbps | ≈ 1.5 Mbps |
| 4 | ≈ 2.5 Mbps | ≈ 2.5 Mbps |
| 6 | ≈ 2.7 Mbps | ≈ 2.7 Mbps |
A broadcast host uploads one stream per viewer (default cap 1200 kbps each). The TURN server only carries the pairs that can't connect directly; size its network for those.
Clocks#
Time-limited logins contain an expiry time. coturn and SmartFoxServer must have correct clocks (NTP) — automatic when both run on the same machine.