Search code examples
webrtcturncoturn

Does it make sense to deploy TURN and media server in the same network?


Suppose, we have a media server S deployed. We have a client C who is behind a symmetric NAT. The direct WebRTC media streaming is not possible due to symmetric NAT. So we want to deploy a TURN server T, which would relay all media between S and C.

Now, it seems that developers sometime deploy T near S for simplicity. But does it help to stream media between C and S? "Near" means "in the same network", so S and T are behind the same NAT if there is some. Since, they are behind the same NAT, it doesn't seem to improve connectivity: chances to stream WebRTC traffic between S and C are the same as between T and C.

Is this reasoning correct or am I missing something? In my current understanding, TURN servers act like a proxy with better connectivity with respect to C. So they should be placed in another network to make any effect.


Solution

  • C -> T can do a few things that C -> S can't do

    • DTLS and TLS transport, ICE only allows UDP and TCP. Some gateways only allow TLS on 443
    • Single port, you can do all traffic on one well know port. Gateway may only allow :443
    • S may not support ICE-TCP. Some SFUs do support it though!