开发者

Chrome remote debugging doesn't work with IP

开发者 https://www.devze.com 2023-03-23 10:48 出处:网络
I\'m trying to remote debugg a chrome instance using the remote debug option in chrome: chrome.exe --remote-debugging-port=1337

I'm trying to remote debugg a chrome instance using the remote debug option in chrome:

chrome.exe --remote-debugging-port=1337

as described on google page: http://code.google.com/chrome/devtools/docs/remote-debugging.html

the problem is when i try to access it using IP it doesn't work, while testing it with local开发者_运维百科host:1337 does work.

any idea?


You can setup an SSH tunnel in order to debug remotely. On the source machine execute:

ssh -L 0.0.0.0:9223:localhost:9222 localhost -N 

Then on the other machine point Chrome browser to http://source-machine-ip:9223


I don't think Chrome accepts connections from outside of localhost (for security reasons). I would suggest you have to build small proxy on the same host where Chrome is.


The following worked for me when running a Chrome remote debugging host on Windows 8.

  1. Add an Inbound Rule to Windows Firewall
    • Search for "Windows Firewall" and select the "Windows Firewall" result
    • On the left of the "Windows Firewall" control panel window, click "Advanced Settings". This will open up "Windows Firewall with Advanced Security".
    • In the tree view on the left, click "Inbound Rules"
    • On the far right, click "New Rule..."
    • Select "Port" (Click Next)
    • Select TCP and set "Specific local ports" to 9222 (Click Next)
    • Select "Allow the connection" (Click Next)
    • Choose the profile access (Domain, Private, Public) to suit your needs (Click Next)
    • Give it a name like Chrome Remote Debugging (9222) (Click Finish)
  2. Follow user3445047's instructions on port forwarding:

Run Chrome on the Windows host:

chrome.exe --remote-debugging-port=9222

Set up port forwarding on the Windows host:

Open up a cmd window. You must "Run as administrator".

Enter the following into the cmd window:

netsh
interface
portproxy
add v4tov4 listenport=9222 connectaddress=127.0.0.1

On the client, navigate to http://THE_HOST_IP_ADDRESS:9222 and you should be presented with a list of "Inspectable Pages".


The easiest way of sharing your debugging session with another computer is with socat. For example, if you've enabled the remote debugging protocol on port 1337 using

chromium --remote-debugging-port=1337

Then, you can create a tunnel using socat,

socat tcp-listen:5656,fork tcp:localhost:1337

After doing this, anyone can just visit http://<YOUR_IP_OR_HOSTNAME>:5656/ and immediately use the debugger.

When you're done, press Ctrl + C to terminate socat and thus stop the tunneling.
If the previous code does not work, check whether the firewall (e.g. iptables) is blocking access. If the firewall is OK, check whether the IP address or host name is actually correct. To see whether the traffic is correctly forwarded/tunnelled, visit http://localhost:5656/ and verify that there's a Webkit debugger instance running.


  1. Start the headless server

    chrome.exe --remote-debugging-port=9222
    
  2. Set up Port forwarding on windows

    netsh interface portproxy add v4tov4^
        listenport=9222 listenaddress=0.0.0.0^
        connectaddress=127.0.0.1 connectport=9222 
    


recent Chrome versions support the commandline switch "--remote-debugging-address" so the workarounds listed above should no longer be necessary.

Here the description: "Use the given address instead of the default loopback for accepting remote debugging connections. Should be used together with --remote-debugging-port. Note that the re-mote debugging protocol does not perform any authentica-tion, so exposing it too widely can be a security risk."


You can create simple TCP proxy with netcat:

EXTERNAL_PORT=1338
CHROME_DEBUG_PORT=1337 # This is the port specified with --remote-debugging-port

nc -l -p ${EXTERNAL_PORT} -c "nc 127.0.0.1 ${CHROME_DEBUG_PORT}"


Try changing port number That works for me.

0

精彩评论

暂无评论...
验证码 换一张
取 消