Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need a TURN server?

Tags:

webrtc

turn

In which cases should I use TURN servers?

Right now I have a WebRTC app that works perfectly. The app is going to be released.

Do I need to set up my own TURN server or maybe this is the case only for major apps?

like image 256
Lauren Avatar asked Oct 16 '22 13:10

Lauren


1 Answers

WebRTC can connect in a few ways, and falls down progressively to lower preference choices as it fails at its first choices.

  1. naive direct p2p with own ip
  2. if that fails, use a STUN server to determine what ip (e.g., router) we're behind
  3. if that fails, true p2p is not possible, use a TURN server instead to relay traffic.

On a typical webRTC app, about 20% of connections require a TURN server. It may work fine for you, but try accessing your webRTC service from a cell phone connection (which will usually require TURN), and you'll see that not all connections are equal when it comes to p2p.

https://www.frozenmountain.com/developers/blog/webrtc-nat-traversal-methods-a-case-for-embedded-turn

This picture shows which types of connections for each party's NAT results in the need for TURN as opposed to STUN.

like image 51
Kyle Baker Avatar answered Oct 21 '22 09:10

Kyle Baker