What is TURN?
TURN stands for "Traversal Using Relay NAT" and is a framework that can be used as an alternative to STUN in order to establish a connection between two servers, or endpoints, that are behind Network Address Translators (NATs) such as a NAT firewall. TURN differs from STUN in that once STUN has helped establish the connection between the two endpoints, its job is done, but a TURN server will continue to be involved in communications between the two endpoints after the connection is established.
The TURN server will continue to act as a relay, buffering all content that is passed from one of the endpoints to the other. This relay functionality implies that the minimum resource requirement for a TURN server is higher than that of a STUN server.
In short, STUN acts as a matchmaking service that allows Orchid Core VMS and web browsers to communicate with each directly. TURN, on the other hand, is more like a traditional proxy--it acts as a middle man by taking data from Orchid Core VMS and then forwarding it to the web browser (and vice versa).
Why use TURN?
STUN is almost always preferable to TURN, but in certain circumstances, such as when using a symmetric NAT firewall, only TURN will work.
In a symmetric NAT, both the public IP address and port of an incoming request are translated to a different local IP address and port. This prevents STUN from working because STUN is only capable of providing the correct IP address for the endpoints and has no knowledge of what the correct port should be. TURN, in contrast, is able to facilitate connections using the translated port information as well.
There are several open-source options available to implement a TURN server, such as coturn. Please see the "Example coturn Configuration File" section below for a sample file.
Additionally, it is typically possible and often advantageous to implement TURN on the same server on which Orchid Fusion is running (if applicable). The feasibility of this option will depend on your network configuration and the hardware resources of the server itself.
Additionally, please note that Orchid currently only supports UDP for WebRTC connections, so you should ensure that UDP is enabled in your TURN server configuration.
Please be advised that IPConfigure does not maintain and is not associated with coturn. Additionally, IPConfigure does not support the configuration or implementation of a STUN or TURN server as part of the standard Orchid Support Agreement.
Orchid Core Configuration
You will need to configure Orchid Core to work with the TURN server using the following entries in the properties file:
- webrtc.turn.host - IP Address of the TURN server. (Note: If the host is set, the port, username, password, and type must also be set.)
- webrtc.turn.port - Port of the TURN server.
- webrtc.turn.username - User name of the TURN server.
- webrtc.turn.password - Password of the TURN server.
- webrtc.turn.type - Relay type of the TURN server, set this as follows: udp
You can find more information on editing the Orchid Core properties file in the Orchid Core VMS Installation Guide in the sections "How to Edit a Configuration File in..." for each supported operating system.
Example coturn Configuration File
fingerprint # required for WebRTC connections
lt-cred-mech # required for WebRTC connections
realm=ipconfigure.com # required for WebRTC connections
user=USERNAME:PASSWORD # this should match what you used in your Orchid Core configuration file
no-stun # Disable this to allow coturn to use STUN when possible
bps-capacity=0 # Total bytes-per-second bandwidth the TURN server is allowed to allocate
stale-nonce=600 # timeout setting for additional security
log-file=/var/tmp/turn.log # optional log file location
Please be advised that if your TURN server is open to the internet, you might consider using a firewall to limit access so that the TURN server will only be used to proxy video streams from an Orchid Core server. You can also accomplish this through the coturn configuration file instead of, or in addition to, using a firewall by blocking IP addresses using a "denied-peer-ip=" line and then whitelisting the IP addresses of the Orchid Core servers by adding a line similar to the following:
Click here for the official coturn documentation for further guidance.