The short answer
WebRTC lets browsers send data directly to each other, but they first need to swap three kinds of message through some server: an offer, an answer and ICE candidates. That swap is called signaling, and it is not defined by WebRTC, so you build or rent it. Once peers are connected, the signaling server is no longer in the data path.
STUN, TURN and ICE in plain words
MDN describes the three pieces:
- ICE is the framework that tries to connect two peers, using STUN and TURN servers as needed.
- STUN tells a client its public address and what kind of NAT it is behind. It does not relay media.
- TURN relays all traffic through a server when a direct connection is impossible, such as behind a symmetric NAT. It is the fallback, and it costs bandwidth.
So a game that only has signaling and STUN will connect many players, and fail for the ones behind restrictive NATs or firewalls.
The message flow
- Player A asks the signaling server for a room and gets a short code.
- Player B joins with the code.
- A creates an offer and sends it to B through signaling.
- B replies with an answer through signaling.
- Both exchange ICE candidates through signaling until a working path is found.
- The data channel opens and play begins, peer to peer.
Pitfalls
| Pitfall | Why it hurts | Mitigation |
|---|---|---|
| No TURN | Some players cannot connect | Tell players honestly and offer a retry; add TURN when you can meter it |
| Trusting peers | No authoritative server, so cheating and desync are easy | Choose WebSocket to a dedicated server if fairness matters |
| Leaking room tokens | Anyone with the token can join the signaling | Treat tokens like passwords; never log them |
| Large rooms | Every peer connects to every other | Keep rooms small |
| No reconnect plan | Mobile tabs sleep and drop | Re-run ICE and resync state |
What NetCraftGames provides
Managed rooms of 2 to 16 peers, WebSocket signaling with room-scoped tokens, exact origin checks and a reference browser connector. It does not provide TURN or a relay for game traffic. The browser WebRTC page has the integration steps and limits.
Frequently asked questions
Do I need a TURN server for a WebRTC game?
Not for every player, but for some. STUN lets most peers find a direct path, yet symmetric NATs and strict firewalls block direct connections, and only a TURN relay can carry their traffic. If you cannot offer TURN, tell players that some networks may fail and provide a clear retry message.
Sources
- MDN: WebRTC protocols (ICE, STUN, TURN), accessed October 3, 2026