2014-03-06 51 views
19

我正在开发一个webrtc应用程序,并且必须实现以下TURN服务器。为WebRTC应用程序实现我们自己的STUN/TURN服务器

https://code.google.com/p/rfc5766-turn-server/

我下面这个教程。

http://www.dialogic.com/den/developer_forums/f/71/t/10238.aspx

,它说引用TURN服务器如下,在其中创建RTCPeerConnection JavaScript代码。

var pc_config = {"iceServers": [{"url": "stun:stun.l.google.com:19302"}, 
    {"url":"turn:[email protected]<turn_server_ip_address>", "credential":"my_password"}]}; 

pc_new = new webkitRTCPeerConnection(pc_config); 

我有点困惑,为什么我们要引用Google的公共STUN服务器。我认为RFC5766 TURN服务器里面有STUN。

RFC5766只是TURN服务器吗?而不是STUN服务器?我们不能使用我们自己的STUN服务器而不是使用Google提供的服务器吗?

对不起,这个天真的问题。我是WebRTC的新手。

谢谢。

回答

14

因为它是STUN的扩展,所以TURN服务器也具有STUN功能。

https://code.google.com/p/rfc5766-turn-server/作品也作为STUN,所以你可以尝试写这样的事:

var pc_config = {"iceServers": [{"url":"turn:[email protected]<turn_server_ip_address>", "credential":"my_password"}]}; 

pc_new = new webkitRTCPeerConnection(pc_config); 
20

只是添加到伊戈尔的回答,

coturnrfc5766-turn-server叉,核心功能是一样的,具有额外的功能,并添加了新的功能,所以我建议你使用它。

在作者自己的话说:

This project evolved from rfc5766-turn-server project (https://code.google.com/p/rfc5766-turn-server/). There are many new advanced TURN specs which are going far beyond the original RFC 5766 document. This project takes the code of rfc5766-turn-server as the starter, and adds new advanced features to it.

至于安装,很容易在Linux机器上,在其他操作系统没有尝试安装。

简单的方法:

sudo apt-get install coturn 

如果你说没有,我想要最新的前沿,你可以从他们的downloads page下载源代码,自行安装,例如:

sudo -i  # ignore if you already in admin mode 
apt-get update && apt-get install libssl-dev libevent-dev libhiredis-dev make -y # install the dependencies 
wget -O turn.tar.gz http://turnserver.open-sys.org/downloads/v4.5.0.6/turnserver-4.5.0.6.tar.gz  # Download the source tar 
tar -zxvf turn.tar.gz  # unzip 
cd turnserver-* 
./configure 
make && make install 

为运行TURN,建议将其作为守护进程运行,并且可以使用此wiki作为配置参考。运行TURN服务器

样本命令:

sudo turnserver -a -o -v -n --no-dtls --no-tls -u test:test -r "someRealm" 

命令描述:

  • -a - 使用长期证书机制
  • -o - 运行服务器进程作为守护
  • -v - '中等'详细模式。
  • -n - 没有配置文件
  • --no-DTLS - 不要启动DTLS听众
  • --no-TLS - 不要启动TLS听众
  • -u - 使用
  • 用户凭据
  • -r - 默认领域使用,需要TURN REST API

现在你可以使用TURN服务器在您的WebRTC应用为:

var peerConnectionConfig = { 
    iceServers: [{ 
    urls: YOUR_IP:3478, 
    username: 'test', 
    password: 'test' 
    }] 
} 
+0

工作就像一个魅力! – Ernest

+3

“someRealm”代表什么? – Loint

+1

“someRealm”代表什么? –

相关问题