Source: https://quadevs.com/insights/webrtc-turn-and-reconnect/

Title: WebRTC TURN server and reconnect logic | quadevs

[Home](https://quadevs.com/)/ [Insights](https://quadevs.com/insights/)/ WebRTC TURN servers and reconnect logic

# WebRTC TURN servers and reconnect logic

Most failed video calls fail on the network between two people. What STUN and TURN each do, and how a call survives a change of network.

Published 2026-11-19 Updated 2026-11-19 5 min read

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](https://quadevs.com/case/video-chat-1to1/) 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](https://www.rfc-editor.org/rfc/rfc8445). ICE collects candidate addresses, tries them in pairs and keeps the first pair that carries media. STUN and TURN supply two kinds of candidates.

| 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](https://www.rfc-editor.org/rfc/rfc8489) | [RFC 8656](https://www.rfc-editor.org/rfc/rfc8656) |

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](https://quadevs.com/webrtc-development/).

1. [STUN vs TURN: what each one does](https://quadevs.com/insights/webrtc-turn-and-reconnect/#stun-vs-turn)
2. [Why a WebRTC connection fails](https://quadevs.com/insights/webrtc-turn-and-reconnect/#why-it-fails)
3. [Reconnect: keeping the call through a network change](https://quadevs.com/insights/webrtc-turn-and-reconnect/#reconnect)
4. [What sits outside the media path](https://quadevs.com/insights/webrtc-turn-and-reconnect/#control-layer)
5. [What to test before launch](https://quadevs.com/insights/webrtc-turn-and-reconnect/#what-to-test)

## Common questions

Do I need a TURN server for WebRTC?

Yes, for a product with real users. Many calls connect directly with STUN alone, but some networks block the direct path, and those calls only work through a relay.

   What is the difference between STUN and TURN?

STUN tells a device its public address so two devices can try to connect directly. TURN carries the media through a server when they cannot. STUN is light; TURN costs bandwidth because the whole call passes through it.

   Why does a WebRTC connection fail on some networks?

Usually because a router hides the device behind a changing address or a firewall blocks UDP. ICE then has no direct pair that works. With a TURN relay among the candidates the call connects anyway.

## We built this in production

[### One-on-one video chat

Real-time · video  WebRTC · STUN/TURN · TypeScript · Node View case](https://quadevs.com/case/video-chat-1to1/)   [### Live video streaming, one-to-many

Real-time · streaming  WebRTC · HLS · CDN · FFmpeg View case](https://quadevs.com/case/video-streaming/)   [### Real-time text messaging

Real-time · messaging  WebSocket · Postgres · Redis pub/sub View case](https://quadevs.com/case/realtime-chat/)

Service [WebRTC development for video chat and streaming](https://quadevs.com/webrtc-development/)

Practice [Web development company for custom web applications](https://quadevs.com/web-development/)

[Send a brief. Reply within 1 business day](https://quadevs.com/contact/)  [or email hello@quadevs.com](mailto:hello@quadevs.com)
