#language en

##TAG:TRANSLATION-HEADER-START
~- [[de/FreedomBox/Manual/Coturn|Deutsch]] - [[FreedomBox/Manual/Coturn|English]] - [[es/FreedomBox/Manual/Coturn|Español]] - [[hu/FreedomBox/Manual/Coturn|Magyar]] - [[DebianWiki/EditorGuide#translation|(+)]] -~
##TAG:TRANSLATION-HEADER-END

<<TableOfContents()>>

## BEGIN_INCLUDE

== Coturn (VoIP Helper) ==
||<tablestyle="float: right;"> {{attachment:Coturn-icon_en_V01.png|Coturn icon}} ||

'''Available since''': version 20.8

Coturn is a server to facilitate audio/video calls and conferences by providing an implementation of [[https://en.wikipedia.org/wiki/Traversal_Using_Relays_around_NAT|TURN]] and [[https://en.wikipedia.org/wiki/STUN|STUN]] protocols. WebRTC, SIP and other communication servers can use it to establish a call between parties who are otherwise unable connect to each other.

It is not meant to be used directly by users. Servers such as Matrix Synapse need to be configured with the details provided on the Coturn app page. Apart from Matrix Synapse, Jitsi, Ejabberd, Nextcloud Talk, etc. can use Coturn server for audio/video calls and conferences. There is no need for the servers to be running on the same machine as !FreedomBox and external servers can use Coturn running on !FreedomBox.

Coturn is configured in !FreedomBox as an advanced app. This means that you need to check "Show advanced apps and features" in "General Configuration" to see Coturn icon in the "Apps" section.

=== How it works ===

When making an audio/video call, it is best to route the media streams between two peers directly. This will give the best possible latency (better signal quality) and avoid depending on a centralized server (privacy). It scales well because a simple chat server can host thousands of calls without involving the server in any way other than to setup the call. However, this approach does not work most of the time due to how networks are configured. Most peers on the network do not have a unique IP address allocated to them. They work hidden behind a network device that performs "Network Address Translation" (NAT) for them. This means that the two peers have no way of reaching each other.

To address this problem, a simple technique known as STUN was introduced. With the help of a third party STUN server, the peers can trick the NAT devices, to carry the traffic between the two peers. Unfortunately, this trick only works about 80% of the time. So, if STUN fails, peers have no choice but to route their traffic through an intermediary server called TURN server. All the mechanism of trying out STUN first and then falling back to TURN is described in a protocol known as [[https://en.wikipedia.org/wiki/Interactive_Connectivity_Establishment|ICE]].

On !FreedomBox, Coturn provides both STUN and TURN servers. Both services are provided over TCP as well as UDP. They are provided on unencrypted as well as encrypted channels (which have a higher chance of success). Since STUN servers are very inexpensive and don't consume a lot of server resources, there is no authentication needed to use them. TURN servers on the other hand need authentication. This authentication is highly simplified and does not require maintaining a database of users. A server such as matrix-synapse which is about to setup an audio/video call between two peers will generate a username and password using a shared secret. When the peers use the TURN server, they will be validated using these credentials because the TURN server also knows the same secret.

In summary, a communication server needs to know the URLs of the STUN/TURN servers along with a shared authentication secret for TURN. After that, during audio/video call setup, they will correctly guide the peers to use STUN/TURN servers. Coturn app in !FreedomBox provides exactly this information. This information can be used to configure a communication server irrespective of whether it is running on the same !FreedomBox or on another server.

=== Configuring Matrix Synapse ===

To configure Matrix Synapse to use Coturn TURN/STUN server, you need to check "Automatically manage audio/video call setup" in Matrix Synapse's configuration section, and then click on "Update seup".

{{attachment:matrix_with_coturn.png|Matrix with Coturn|width=800}}

=== Port Forwarding ===

If your !FreedomBox is behind a router, you will need to set up port forwarding on your router. You should forward the following ports for Coturn:
 * UDP 3478
 * TCP 3478
 * UDP 3479
 * TCP 3479
 * UDP 5349
 * TCP 5349
 * UDP 5350
 * TCP 5350
 * UDP 49152-50175
 * TCP 49152-50175


=== External links ===

 * Upstream project: https://github.com/coturn/coturn
 * Upstream end user documentation: https://github.com/coturn/coturn/wiki/


## END_INCLUDE

Back to [[FreedomBox/Features|Features introduction]] or [[FreedomBox/Manual|manual]] pages.


<<Include(FreedomBox/Portal)>>

----
CategoryFreedomBox
