Turn服务器的配置流程git
Webrtc是基于P2P的,在两个客户端创建链接以前须要服务器创建链接,这时两台设备通常都处于一个或者多个NAT中,那么两台设备创建链接就须要穿墙技术。github
这时就用到了turn服务器,他包括stun服务器,stun服务器主要用来得到外网的地址,而turn服务器则负责在P2P链接失败时进行转发web
推荐一个部署turn服务器的方式,下载地址https://github.com/coturn/coturnubuntu
下载完成之后进行安装,cd到下载coturn的目录下服务器
执行./configureui
makeurl
make installserver
执行时会报错Libevent2 development is not installed properlyblog
ERROR: Libevent2 development libraries are not installed properly in required location.ip
ERROR: may be you have just too old libevent tool - then you have to upgrade it.
See the INSTALL file.
说明你须要安装libevent,以ubuntu为例执行命令进行安装sudo apt-get install libevent-dev
若是执行成功会在conturn的bin目录下生成一些文件
配置iceServer
turnserver -o -a -f -v --mobility -m 10 --max-bps=100000 --min-port=32355 --max-port=65535 --user=username1:password1 --user=username2:password2 -r demo –m 10
其中username1和username2分配了两个不一样的帐号和密码
在服务器内的配置
webrtc的服务器通常使用SkyRTC,下载地址https://github.com/LingyuCoder/SkyRTC-demo
下载后按照文档进行安装和配置
配置stun须要在SkyRTC-client.js
内配置iceServers,配置的端口默认是3478,格式以下
“url“: 'stun:ip:3478'
“username”: 'username1’
“password”:’password1’