问题描述
Chrome具有非常强大的功能,可让您从其他浏览器或窗口打开开发工具.可以通过使用以下标志启动chrome来工作:
Chrome has a really awesome feature that allows you to open the dev tools from another browser or window. It works by starting chrome with this flag:
--remote-debugging-port=9222
然后从另一个窗口/浏览器中,您可以转到 http://localhost:9222 并打开可运行的开发工具Chrome中的标签.出于安全原因,Chrome不允许通过IP从另一台计算机进行访问,可以说 http://192.168.1.2:9222
Then from another window/browser you can go to http://localhost:9222 and open dev tools for any running tab in Chrome. For security reasons Chrome will not allow access from another machine by IP, lets say http://192.168.1.2:9222.
不过,还有一个额外的标志表明它开启了此功能,这是Chrome不得不说的:
However there is an additional flag that indicates it opens this ability, here is what Chrome has to say for it:
--remote-debugging-address
要么它不起作用,要么我不知道如何格式化它.我尝试了以下方法:
Either it's not working or I have no idea how to format it. I have tried the following:
--remote-debugging-port=9222 --remote-debugging-address=http://192.168.1.2:9222
--remote-debugging-port=9222 --remote-debugging-address=http://192.168.1.2
--remote-debugging-port=9222 --remote-debugging-address=192.168.1.2:9222
--remote-debugging-port=9222 --remote-debugging-address=192.168.1.3 //maybe thinking its supposed to be the IP of the remote machine
目标计算机为Mac
推荐答案
原来,选项"--remote-debugging-address"只能用于无头模式("--headless"),并且当浏览器在docker容器中运行时用于测试,而不用于远程调试.
it turned out, that the option "--remote-debugging-address" can only be used for the headless mode ("--headless") and is intended to be used for tests when the browser runs in a docker container and not for remote debugging.
"remote-debugging-address"参数必须是使用"--remote-debugging-address"启动Chrome的计算机的本地网络接口的IP地址.使用任何非本地ip地址时,都会出现以下错误:
The parameter of "remote-debugging-address" must be the numeric ip-adress of a local network interface of the machine where you start Chrome with "--remote-debugging-address".When using any non-local ip-address you will get the following errors:
[0526/132024.480654:ERROR:socket_posix.cc(137)] bind() returned an error, errno=49: Can't assign requested address
[0526/132024.480766:ERROR:devtools_http_handler.cc(226)] Cannot start http server for devtools. Stop devtools.
在Mac上,我可以使用以下命令行从今天开始启动Chrome Canary版本(当前的稳定版本仅会以"--headless"崩溃):
On my Mac I can start the Chrome Canary version from today using this command line (the current stable version just crashes with "--headless"):
/Applications/Google\ Chrome\ Canary.app/Contents/MacOS/Google\ Chrome\ Canary --remote-debugging-port=9222 --remote-debugging-address=192.168.1.20 --headless
在另一个外壳中,您可以看到该地址用于侦听套接字:
In another shell you can see, that this address is used to listen on the socket:
netstat -a -n | grep 9222
tcp4 0 0 192.168.1.20.9222 *.* LISTEN
没有"--headless"的输出将如下所示:
Without "--headless" the output will look like this:
tcp4 0 0 127.0.0.1.9222 *.* LISTEN
迈克尔
这篇关于从另一台计算机进行Chrome远程调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!