ubuntu - Ubuntu 和 Puppeteer 没有 srvflx 地址
问题描述
我想做的事
使用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"
}
]
解决方案
如果您的机器配置了公共 IP 并且不在 NAT 后面(这是 ubuntu 的候选主机建议),则不会返回 srflx 候选,因为 serverreflexive 地址与主机地址相同。有关详细信息,请参阅https://www.rfc-editor.org/rfc/rfc8445#section-5.1.3。
推荐阅读
- javascript - 如何使用 Playwright 打开新标签(例如单击按钮在新标签中打开新部分)
- rust - 有没有办法防止格式化 else { 琐碎的表达式 }
- c - 分段错误(核心转储)运行时错误
- unity3d - 按下按钮时无法做出平滑的旋转角度
- android - 我正在开发一个基于 CameraX 库的相机应用程序。问题是为什么 CameraX isExtensionAvailable 方法总是返回 FALSE?
- laravel - 三个(或四个?)模型之间的雄辩关系
- javascript - 关于 Promise Then
- pandas - 第二个 csv 文件的长度不等于使用 np.select 的基本文件
- python - 组内连续行与创建相同的字符串之间的数据帧差异
- jms - 我们如何阻止 ibm mq amqp 订阅者访问其他订阅者的主题?