Ubuntu 和 Puppeteer 没有 srvflx 地址

Posted

技术标签:

【中文标题】Ubuntu 和 Puppeteer 没有 srvflx 地址【英文标题】:No srvflx adress with Ubuntu and Puppeteer 【发布时间】:2020-03-27 06:15:30 【问题描述】:

我想做的事

使用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 设置木偶: 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"
            
    ]

【问题讨论】:

【参考方案1】:

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

【讨论】:

以上是关于Ubuntu 和 Puppeteer 没有 srvflx 地址的主要内容,如果未能解决你的问题,请参考以下文章

centos及ubuntu安装 Puppeteer/rendertron所需的依赖包

无法在 Ubuntu 16.04 AWS EC2 实例上使用 puppeteer 启动 chromium headless

sh ubuntu linux上的puppeteer ami(xvfb setup)+用于自动缩放的cloudwatch指标

CronJob 没有运行

CronJob 没有运行

CronJob 没有运行