Coturn stun 服务器返回代码为 701 的错误

Coturn stun server returned an error with code=701

我有自己的服务器 ubuntu 19.

注意:我需要一个 stun/turn 服务器用于视频聊天 Web 应用程序。如果两个设备都在同一个网络中,它已经可以工作了。

我已经成功安装并配置了coturn。我可以通过 运行 成功启动 turnserver: turnservernohup turnserver & 在终端中。

注意:我有 SSH 连接到我的服务器。

我还确保打开了必要的端口并使用 netstat -tulpn 检查了它们。

我在测试时也重启了几次 coturn sudo service coturn restart

我在turnserver.conf中使用这些配置:

# Also tried 80
listening-port=3478
# Also tried 443
tls-listening-port=5349
listening-ip=<MY-IP4>
listening-ip=<MY-IP6>
relay-ip=<MY-IP4>
external-ip=<MY-IP4>
oauth
user=root:<password>
userdb=/var/lib/turn/turndb
no-stdout-log

这是我在 js 中的 iceServers 配置,我相信它应该可以工作(我已经完成了大量的其他组合)。

var pcConfig = {
  'iceServers': [
    {
      'urls': 'stun:<MY-IP4>:80'
    },
    {
      'urls': 'turn:<MY-IP4>:80',
      'credential': '<PASSWORD>',
      'username': 'root'
    }
  ]
};

我已经完成了大量不同的 stun/turn 服务器组合,例如:

我也一直在我的网络项目和这里进行现场测试: https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/

基本上上面的测试URL总是给我:

Note: errors from onicecandidateerror above are not neccessarily fatal. For example an IPv6 DNS lookup may fail but relay candidates can still be gathered via IPv4.
The server stun:<MY-IP4>:80 returned an error with code=701:
STUN server address is incompatible.
The server stun:<MY-IP4>:80 returned an error with code=701:
STUN server address is incompatible.

不管我用google的stun服务器还是我自己的,错误都是一样的。

如果我使用同一个网络,我的网络项目和视频聊天效果很好,但我相信 stun 和 turn 服务器不在同一个网络中使用。

另外,当我更新我的 JS 文件时,我总是删除缓存,所以使用了新的 JS 文件。所以这也不是问题。

编辑

这个组合不会报错,只有:

Note: errors from onicecandidateerror above are not 
neccessarily fatal. For example an IPv6 DNS 
lookup may fail but relay candidates can still be gathered via IPv4.

测试于 https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/

{
  'urls': 'stun:<MY-IP6>:80'
},
{
  'urls': 'turn:<MY-IP4>:80',
  'credential': '<PASSWORD>',
  'username': 'root'
}

我只是简单地用了 IP6 的眩晕和 IP4 的回合。 在不同的网络中视频聊天仍然无法正常工作,找不到其他错误。

编辑:

今天注意到 https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/ 不起作用。我在 firefox 上没有错误。但是你可以在那里输入一些废话,它也不会显示错误...

编辑:

我还添加了现在有效的证书:

cert=/usr/local/etc/turn.pem                                                                                    
pkey=/usr/local/etc/turn.key.pem

似乎有效。我重新启动了 coturn,状态告诉我一切 运行 都没有问题。

视频聊天在不同的网络中仍然不起作用。

好的。我从错误的角度看整件事。 TURN/STUN 服务器设置正确。

问题出在 client/server 代码上。信号不起作用。

我遵循了 this 文章,但我在设置信令服务时遇到问题。我认为这必须在一个新问题中提出。