Do you need TURN?
Public STUN is enough for most home connections. Behind a symmetric NAT the direct path never opens, and without TURN those players fall back to the server relay: the game still works, but at a higher cost and latency. TURN brings them back to direct peer-to-peer.
Measure before you buy. The dashboard's Usage tab shows the share of ticks actually held peer-to-peer. If direct connections often fail, add TURN. In code, room.on('transport', mode => …) reports p2p, mixed or relay.
Configure it in one object
Two forms in the game configuration. Prefer the first: the secret never leaves the server, and each client receives an expiring credential following the coturn shared-secret convention. Per the reference, this is understood as-is by Cloudflare, Twilio, Xirsys and most managed TURN services.
// A) shared secret + expiring credentials (recommended)
{ "turn": { "urls": ["turn:turn.example.com:3478"], "secret": "...", "ttl": 3600 } }
// B) static ICE servers (if your provider hands out fixed credentials)
{ "ice": [ { "urls": "turn:turn.example.com:3478", "username": "...", "credential": "..." } ] }The SDKs renew the list on their own; GET /v1/rt/ice returns it with its ttl.
Self-host or buy?
| Option | Pros | Cons |
|---|---|---|
| coturn (self-host) | Cheapest per GB, full control | You run it: TLS, ports, monitoring, regions |
| Managed TURN (Xirsys, Twilio, Cloudflare and similar) | Global footprint, no ops | Metered bandwidth; check current pricing |
| Server relay only (default) | Zero setup | Higher cost and latency for the players who need it |
Start with the default relay, watch the Usage tab, and add TURN only if a meaningful share of players is relayed. Background reading: WebRTC multiplayer without a server.
What is a TURN server and why do games need one?
A TURN server relays traffic between peers when a direct WebRTC connection is impossible, typically behind symmetric NATs. Without it, those players cannot connect peer-to-peer.
Does Multiplayer API work with Xirsys?
Yes. Declare the TURN URLs and either a shared secret with a TTL or static ICE credentials in the game configuration; clients receive them from the ICE endpoint.
What happens if I do not configure TURN?
Players who cannot connect directly are served through the server relay. The game continues; only that pair of peers is affected.
Make your game online today
Free sandbox keys in one call, no account and no card. $19.99/month when you ship, for every game you make.
Free sandbox · $19.99/mo to go live · cancel anytime