gpt4 book ai didi

webrtc - 为 WebRTC 应用程序实现我们自己的 STUN/TURN 服务器

转载 作者:行者123 更新时间:2023-12-02 23:18:47 36 4
gpt4 key购买 nike

我正在开发一个 webrtc 应用程序,并且必须实现以下 TURN 服务器。

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

我正在学习本教程。

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

它表示在创建 RTCPeerConnection 的 JavaScript 代码中按如下方式引用 TURN 服务器。

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

pc_new = new webkitRTCPeerConnection(pc_config);

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

RFC5766 是唯一的 TURN 服务器吗?而不是 STUN 服务器?难道我们不能实现自己的 STUN 服务器而不是使用 Google 提供的服务器吗?

抱歉问这么幼稚的问题。我是 WebRTC 新手。

谢谢。

最佳答案

TURN是STUN的扩展,因此TURN服务器也具有STUN功能。

https://code.google.com/p/rfc5766-turn-server/也可用作 STUN,因此您可以尝试编写如下内容:

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

pc_new = new webkitRTCPeerConnection(pc_config);

关于webrtc - 为 WebRTC 应用程序实现我们自己的 STUN/TURN 服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22233980/

36 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com