Pre-launch.NetCraftGames is not accepting customers yet. Launch happens only after its public checks pass.See launch statusJoin the waitlist

Guides

WebRTC signaling for browser games, explained

A signaling server lets two browsers exchange the handshake messages they need to connect directly. It does not carry game traffic. STUN finds public addresses; only a TURN server relays data when a direct path is blocked. Without TURN, some players will not connect.

By Charging Bull SoftwareLast updated:

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

  1. Player A asks the signaling server for a room and gets a short code.
  2. Player B joins with the code.
  3. A creates an offer and sends it to B through signaling.
  4. B replies with an answer through signaling.
  5. Both exchange ICE candidates through signaling until a working path is found.
  6. The data channel opens and play begins, peer to peer.

Pitfalls

PitfallWhy it hurtsMitigation
No TURNSome players cannot connectTell players honestly and offer a retry; add TURN when you can meter it
Trusting peersNo authoritative server, so cheating and desync are easyChoose WebSocket to a dedicated server if fairness matters
Leaking room tokensAnyone with the token can join the signalingTreat tokens like passwords; never log them
Large roomsEvery peer connects to every otherKeep rooms small
No reconnect planMobile tabs sleep and dropRe-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