我尝试按照https://chromedevtools.github.io/devtools-protocol/上的基础知识:使用 DevTools 作为协议客户端中描述的步骤进行操作。我使用
google-chrome --remote-debugger-port=9222
启动了两个 Chrome 实例
和google-chrome --user-data-dir=/home/whatever/Desktop/chrome/
。之后,我导航到 http://127.0.0.1:9222/
,但收到“无法访问此网站”错误页面。
如果我使用
google-chrome --headless --remote-debugging-port=9222
启动 Chrome,那么当我导航到 http://127.0.0.1:9222/
时,我可以看到“Inspectable WebContents”和指向空白页面的链接。
有人知道为什么
remote-debugging-port
标志仅适用于无头实例吗?据我所知,它应该是双向的。
注意:我尝试的是能够使用
connect
方法在 Chorme 实例上使用 Puppeteer (https://github.com/GoogleChrome/puppeteer/blob/master/docs/api.md#puppeteerconnectoptions )。
我设法通过启动 chrome 使其正常工作,如下所示:
google-chrome --remote-debugging-port=9222 --user-data-dir=/home/whatever/Desktop/chrome/
尝试忽略空白页和首次访问
http://localhost:9222/json
然后从 JSON 检查 devtoolsFrontendUrl 并转到
http://localhost:9222/
我写了一篇关于如何设置 Chrome 远程调试的文章,其中涵盖了此修复https://devforth.io/blog/chrome-remote-debugging-setup/