webrtc服务如果只是局域网内测试,可以不需要这个,但如果要放在外网就需要搭建 turn服务,今天在服务器上就尝试搭建了一下
ubuntu14.04
sudo apt-get install libssl-dev
sudo apt-get install libevent-dev
sudo apt-get install libpq-dev
sudo apt-get install mysql-client
sudo apt-get install libmysqlclient-dev
sudo apt-get install libhiredis-dev
sudo apt-get install git
sudo apt-get install make
安装 coturn
git clone https://github.com/coturn/coturn
cd coturn/
./configure --prefix=/alidata/soft
make
sudo make install
中间会碰见如果有依赖没有安装的话,就需要自己安装依赖
启动服务
这里就需要了解下区别 stun 和turn
https://developer.aliyun.com/article/243540
- turn
turnserver -o -v -f -a -m 2 --max-bps=100000 --min-port=32355 --max-port=65535 --user=phz:1 -r phzled.cn -L your.ip
- stun
turnserver -o -f -v -a -m 2 --max-bps=100000 --min-port=32355 --max-port=65535 --user=phz:1 -r phzled.cn -X <public ip/ private ip> -X <public ip/ private ip>
参数说明
-
-o 以守护进程模式运行(后台运行)
-
-v 日志会以“适度详细”的程度来记录
-
-f 增加指纹机制。
-
-a 长期验证机制
-
-m 以x个进程来处理中继请求
-
–max-bps 带宽
-
–min-port 起始用的最小端口
-
–max-port 最大端口号
-
–user=帐号:密码 (随便写啥都行,记得住就行,turn服务的用户验证机制要用)
-
-r 领域(随便写啥都行)。如果turn服务器没有使用任何数据库/命令行/conf文件进行配置,就需要加这个选项,并且要配合long-term credentials(-a选项)使用
-
-L 监听IP(turn服务器的ip)这个ip是你ifconfig查到的ip,不是你的公网ip
-
-X 后面加 public ip/ private ip 多IP情况下使用,有几个ip就用几次
检测地址
https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/
免费stun服务列表
stun:stun1.l.google.com:19302
stun:stun2.l.google.com:19302
stun:stun3.l.google.com:19302
stun:stun4.l.google.com:19302
stun:23.21.150.121
stun:stun01.sipphone.com
stun:stun.ekiga.net
stun:stun.fwdnet.net
stun:stun.ideasip.com
stun:stun.iptel.org
stun:stun.rixtelecom.se
stun:stun.schlund.de
stun:stunserver.org
stun:stun.softjoys.com
stun:stun.voiparound.com
stun:stun.voipbuster.com
stun:stun.voipstunt.com
stun:stun.voxgratia.org
stun:stun.xten.com
``