Traversal Using Relays around NAT (TURN) is a protocol that assists in traversal of network address translators (NAT) or firewalls for multimedia applications.
For most WebRTC applications to function a server is required for relaying the traffic between peers, since a direct socket is often not possible between the clients (unless they reside on the same local network). The common way to solve this is by using a TURN server.
There are currently several options for TURN servers available online, both as self-hosted applications (like the open-source COTURN project) and as cloud provided services.
In this article I describe how to setup your own TURN server on your AWS instance. Below are the steps.
tar xvfz libevent-2.1.8-stable.tar.gz
sudo make install
Go to Coturn and download the latest version. I used turnserver-18.104.22.168.tar.gz.
tar xvfz turnserver-22.214.171.124.tar.gz
Setup TURN server users (for more info see Coturn Wiki).
sudo turnadmin -A -u admin -p s3cret
Start the server as a daemon (Note STUN requires username and password otherwise it will reject any requests!)
$ screen -S "coturn" -dm turnserver -u 'rtcrandom:s3cret' -v -n -p 3478 -L 172.31.25.195 -r rtcrandom -X 126.96.36.199\172.31.25.195 --no-dtls --no-tls