I have been doing WebRTC recently. I always preferred ICE to be relayed. This means, all WebRTC connections will be relayed, and ignore STUN, or P2P. My SFU, and relay servers were hosted in EC2 instances. SFU are docarized, but TURN servers are not. Right now, I am only interested with UDP relay, and password based ( key-pair ) authentication. So, this setup will only work with UDP relay, and no rest-based authentication will not work with this installation. I don't recommend key-pair authentication. It is recommended to add some extra layer of verification by adding time-stamp, server-token if you really want to support password ( key-pair ) based authentication.
I am using an Ubuntu 14.04 EC2 image.
I am using an Ubuntu 14.04 EC2 image.
- Install Dependencies
sudo apt-get update &&
sudo apt-get install -y build-essential \
golang git libav-tools libavcodec-dev \
libavcodec-extra libavformat-dev zip unzip \
libmicrohttpd-dev libjansson-dev libnice-dev \
libssl-dev libsrtp-dev libsofia-sip-ua-dev libglib2.0-dev \
libopus-dev libogg-dev pkg-config gengetopt libtool automake wget cmake vim sqlite3 libsqlite3-dev
- Install libevent
wget https://github.com/downloads/libevent/libevent/libevent-2.0.21-stable.tar.gz
tar xvfz libevent-2.0.21-stable.tar.gz
cd libevent-2.0.21-stable
./configure
make
sudo make install
- Install CoTurn
wget -c https://github.com/coturn/coturn/archive/4.5.0.3.tar.gz
tar -xzvf 4.5.0.3.tar.gz
cd coturn-4.5.0.3/
./configure
make
sudo make install
- Run CoTurn
PRIVATE_IP=`curl http://169.254.169.254/latest/meta-data/local-ipv4 2> /dev/null`
PUBLIC_IP=`curl -4 icanhazip.com 2> /dev/null`
sudo sh -c "nohup turnserver --syslog -a -L ${PRIVATE_IP} -X ${PUBLIC_IP} -E ${PRIVATE_IP} -f --min-port=1024 --max-port=65535 --user=ninefingers:youhavetoberealistic -r realm --log-file=stdout &"Th
- This will start CoTurn server as a background process. To stop the co-turn, you will need to find the process Id ( PID ), and kill the process.
sudo ps aux | grep turn
sudo kill -9 "current coturn process id"
- I had to open UDP ports 1024-65535 for for amazon instance. For simplicity, right now I opened all incoming UDP ports for Turn server.