如何调试ICE Candidate的选择? [英] How to debug the selection of ICE Candidate?

查看:38
本文介绍了如何调试ICE Candidate的选择?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在同一网络上的两台笔记本电脑之间创建 WebRTC 连接.我希望 TURN 服务器不会被选为连接,但目前是.我查看了 ICE 候选人,他们似乎将我的轮换服务器放在优先级最低的位置.这是我的状态的 JSON 表示:

I'm creating a WebRTC connection between two laptops on the same network. I would expect the TURN server to NOT be chosen as the connection, but it currently is. I've taken a look at the ICE candidates and they seem to have my turn server as the bottom in terms of priority. Here's a JSON representation of my state:

 "connection": {
    "version": 4,
    "ip": "64.227.54.86\\r\\n"
  },
  "candidates": [
    {
      "foundation": 175723363,
      "component": 1,
      "transport": "udp",
      "priority": 2122260223,
      "ip": "192.168.86.64",
      "port": 64242,
      "type": "host",
      "generation": 0,
      "network-id": 1,
      "network-cost": 50,
      "_priority": "126 | 32542 | 255"
    },
    {
      "foundation": 2335266263,
      "component": 1,
      "transport": "udp",
      "priority": 1686052607,
      "ip": "24.6.16.241",
      "port": 64242,
      "type": "srflx",
      "raddr": "192.168.86.64",
      "rport": 64242,
      "generation": 0,
      "network-id": 1,
      "network-cost": 50,
      "_priority": "100 | 32542 | 255"
    },
    {
      "foundation": 1157279635,
      "component": 1,
      "transport": "tcp",
      "priority": 1518280447,
      "ip": "192.168.86.64",
      "port": 64852,
      "type": "host",
      "tcptype": "passive",
      "generation": 0,
      "network-id": 1,
      "network-cost": 50,
      "_priority": "90 | 32542 | 255"
    },
    {
      "foundation": 1039353576,
      "component": 1,
      "transport": "udp",
      "priority": 41885695,
      "ip": "64.227.54.86",
      "port": 38537,
      "type": "relay",
      "raddr": "24.6.16.241",
      "rport": 64242,
      "generation": 0,
      "network-id": 1,
      "network-cost": 50,
      "_priority": "2 | 32543 | 255"
    },
    {
      "foundation": 1936767512,
      "component": 1,
      "transport": "udp",
      "priority": 25108223,
      "ip": "64.227.54.86",
      "port": 57994,
      "type": "relay",
      "raddr": "24.6.16.241",
      "rport": 64851,
      "generation": 0,
      "network-id": 1,
      "network-cost": 50,
      "_priority": "1 | 32542 | 255"
    }
  ],

我的问题是,有没有办法调试为什么会选择一个特定的 ICE 候选人而不是其他人?我很想知道为什么选择了一个特定的.

My question is, is there a way to debug why exactly a particular ICE candidate is chosen over others? I would love to understand why a particular one is chosen.

为了提供更多上下文,当存在完全有效的非 TURN 连接路径时,ICE 将选择 TURN 服务器作为连接.通过从 ICE 服务器列表中删除 TURN 服务器并让一切正常工作来确认这一点.

To provide a bit more context, ICE is selecting a TURN server as the connection when there is a perfectly valid non-TURN connectivity pathway that is possible. This is confirmed by taking off the TURN server from the ICE server list and having everything work.

推荐答案

这个 statckoverflow post 会帮助你.总之

This statckoverflow post will help you. In short

每个 ICE 都包含您网络的一个节点",直到它到达外部.通过这种方式,您将这些 ICE 发送给其他对等方,以便他们知道他们可以通过哪些连接点联系到您.把它看成一个大建筑:一个人在大楼里,需要告诉另一个(不熟悉的人)如何穿过它.在这里也是一样,如果我有很多网络设备,传入的连接需要以某种方式找到我的计算机的正确方式.通过提供所有节点,RTC 连接自己找到最短路径.因此,当您连接到您旁边的计算机时,该计算机连接到同一路由器/交换机/任何东西,它会使用所有 ICE 并确定最短的,即直接通过该点.您的同事获得较少的 ICE 候选人与它必须经过的设备数量有关.请注意,您计算机中的每个网络适配器都有一个 IP 地址(我有一个来自 hyper-v 的 vEthernet 交换机),它也会为它创建一个 ICE

Every ICE contains 'a node' of your network, until it has reached the outside. By this you send these ICE's to the other peer, so they know through what connection points they can reach you. See it as a large building: one is in the building, and needs to tell the other (who is not familiar) how to walk through it. Same here, if I have a lot of network devices, the incoming connection somehow needs to find the right way to my computer. By providing all nodes, the RTC connection finds the shortest route itself. So when you would connect to the computer next to you, which is connected to the same router/switch/whatever, it uses all ICE's and determine the shortest, and that is directly through that point. That your colleague got less ICE candidates has to do with the number of devices it has to go through. Please note that every network adapter inside your computer which has an IP address (I have a vEthernet switch from hyper-v) it also creates an ICE for it

这篇关于如何调试ICE Candidate的选择?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆