A TURN server relays the media of a WebRTC call when the two devices cannot reach each other directly. STUN, the lighter protocol beside it, only tells a device its public address. A call that works in the office and fails for customers is often missing TURN, or it handles a network change badly.

This note comes from building one-to-one video calls for healthcare visits, support teams and creator platforms. The clients had tried ready-made SDKs first. Reconnecting turned out to be the hardest part: a user who lost one call rarely trusted the product again.

STUN vs TURN: what each one does

WebRTC finds a path between two devices with ICE, described in RFC 8445. ICE collects candidate addresses, tries them in pairs and keeps the first pair that carries media. STUN and TURN supply two kinds of candidates.

STUN vs TURN: what each one does
Question STUN TURN
What it does Tells a device the address the outside world sees Carries the media through a relay both sides can reach
Media path Direct, device to device Through the relay server
Server load A few small packets per call The whole call passes through it
Defined in RFC 8489 RFC 8656

STUN is cheap, so every call tries it. TURN costs bandwidth, so it is the last candidate ICE tries. A product needs both, because nobody can know in advance which calls will need the relay.

Why a WebRTC connection fails

Two kinds of network defeat the direct path. Some routers give a device a different public address for every destination, so the address learned through STUN is useless to the other caller. Some firewalls block the UDP traffic that media prefers. In both cases ICE finds no direct pair that works. Without a relay candidate it gives up, and the user sees a call that never connects.

Our platform falls back from STUN to TURN for these calls. The user notices nothing, and the call runs through the relay.

Reconnect: keeping the call through a network change

A call that connected can still lose its path. A phone leaves Wi-Fi for mobile data, or part of the route drops for a few seconds. WebRTC has a standard tool for this, the ICE restart: both sides gather fresh candidates and agree a new path while the session stays the same.

We built the reconnect logic so that the call stays alive when part of the network fails. The two people stay in the same session, and nobody has to dial again. On a healthcare visit that is the difference between a pause and a missed appointment.

What sits outside the media path

Signalling is separate from media. In our build a TypeScript layer on Node handles the signalling and never touches the audio or video, which stay encrypted between the callers or the relay. The same layer collects delay and quality figures for each call and sends them to the client's dashboards, so a support team can look into a session after it ends.

Recording follows the same rule of separation. It starts only behind a clear consent prompt.

What to test before launch

Office Wi-Fi proves little. Three tests show how a call behaves for real users. Call from a phone on mobile data to a laptop behind a company firewall. Switch the phone from Wi-Fi to mobile data in the middle of a call. Block UDP on one side and check that the relay takes over. If all three pass on the devices your users own, the hard cases are covered. The service behind this work is our WebRTC development.