ubuntu - Ubuntu 和 Puppeteer 没有 srvflx 地址

标签 ubuntu webrtc puppeteer

我想做的事

使用https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/收集一个 srvflx 候选人。

问题:

无法在 Ubuntu Server(Linux) 上接收 srvflx 候选。在 Windows 上工作。

重现步骤:

操作系统 Ubuntu 19.04 安装

  • sudo apt-get update && apt-get upgrade
  • sudo ufw disable
  • curl ipecho.net/plain//返回一个可 ping 通的 ip

  • 设置 puppeteer :
  • curl -sL https://deb.nodesource.com/setup_13.x | sudo -E bash - && sudo apt-get install -y nodejs
  • mkdir -p /tmp/puppeteertest && cd /tmp/puppeteertest && npm init
  • npm i puppeteer --save
  • 安装此处列出的所有库 https://github.com/puppeteer/puppeteer/blob/master/docs/troubleshooting.md#chrome-headless-doesnt-launch-on-unix
  • sudo apt-get install -y gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget
  • vi index.js//使用下面的代码创建 index.js

  •     const puppeteer = require('puppeteer');
    
        (async () => {
          const browser = await puppeteer.launch({
            headless: true,
            args: [
              "--no-sandbox",
              "--disable-features=WebRtcHideLocalIpsWithMdns",
              "--disable-setuid-sandbox"
            ]
          });
    
          const pages = await browser.pages();
          const page = pages[0];
          await page.goto('https://webrtc.github.io/samples/src/content/peerconnection/trickle-ice/');
          // Start gathering
          await page.click("#gather");
          await page.waitFor(5000);
    
          // Scrape candidates
          const respItems = [];
          const tableContainer = await page.$('#candidatesBody');
          const trsElem = await tableContainer.$$('tr');
    
          for (let trElem of trsElem) {
            const dataList = await trElem.$$eval('td', tdsElem => tdsElem.map(td => td.innerText));
            respItems.push({
              time: dataList[0],
              compoment: dataList[1],
              type: dataList[2],
              foundation: dataList[3],
              protocol: dataList[4],
              address: dataList[5],
              port: dataList[6],
              priority: dataList[7],
            });
          };
    
          console.log(JSON.stringify(respItems, null, "\t"));
          await browser.close();
          process.exit(0);
        })();
    


  • node index.js

  • 输出窗口
    [
            {
                    "time": "0.009",
                    "compoment": "rtp",
                    "type": "host",
                    "foundation": "1879246603",
                    "protocol": "udp",
                    "address": "[LOCAL IP]",
                    "port": "55810",
                    "priority": "126 | 30 | 255"
            },
            {
                    "time": "0.028",
                    "compoment": "rtp",
                    "type": "srflx",
                    "foundation": "842163049",
                    "protocol": "udp",
                    "address": "[PUBLIC IP]",
                    "port": "55810",
                    "port": "55810",
                    "priority": "126 | 30 | 255"
            },
            {
                    "time": "0.028",
                    "compoment": "rtp",
                    "type": "srflx",
                    "foundation": "842163049",
                    "protocol": "udp",
                    "address": "[PUBLIC IP]",
                    "port": "55810",
                    "priority": "100 | 30 | 255"
            },
            {
                    "time": "0.110",
                    "compoment": "Done"
            },
            {
                    "time": "0.112"
            }
    ]
    

    输出 Ubuntu
        [
                {
                        "time": "0.007",
                        "compoment": "rtp",
                        "type": "host",
                        "foundation": "3461618340",
                        "protocol": "udp",
                        "address": "[PUBLIC IP]",
                        "port": "45743",
                        "priority": "126 | 30 | 255"
                },
                {
                        "time": "0.109",
                        "compoment": "Done"
                },
                {
                        "time": "0.111"
                }
        ]
    

    最佳答案

    如果您的机器配置了公共(public) IP 并且不在 NAT 后面(这是 ubuntu 的候选主机建议),则不会返回 srflx 候选,因为 serverreflexive 地址与主机地址相同。见 https://www.rfc-editor.org/rfc/rfc8445#section-5.1.3详情。

    关于ubuntu - Ubuntu 和 Puppeteer 没有 srvflx 地址,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59142220/

    相关文章:

    webrtc - 多方视频聊天-检测对端说话人

    android - WebRTC : gclient runhooks not working

    javascript - 如何使用 JS/Puppeteer 上传文件

    javascript - Puppeteer 获取所有数据属性值

    c - 为什么不能触发子进程中的信号处理程序?

    ubuntu - 在hadoop-2.6.0多节点安装中无法格式化namenode

    ubuntu - 创建表时出现 HBase 错误

    java - 使 Oracle JDK 在 Ubuntu 或 GNU/Linux 操作系统中自动更新

    webrtc - 无法使用适用于 Android 的 apprtc 和 apprtcdemo 创建对等

    javascript - 将 JavaScript 注入(inject) Puppeteer 的最佳方法是什么?