Launch configuration in VS Code to connect to a Chrome instance which runs on a different computer?

1.3k views Asked by At

I am aware that there is a million of questions which ask (and get answered) how to launch Chrome or attach to it and then debug a web site from within VS Code.

I have nearly the same question, but in my case, the browser which should be debugged runs on a different computer.

Microsoft states that this is possible, and the IntelliSense popups in the launch configuration editor make me believe it. However, I've never seen an example of it, and haven't had success myself when trying it a few times in the past, although I've put quite some time into that subject.

Specifically, in a Windows 10 system which has Chrome installed, I do the following:

  • Close all instances of Chrome and use the Windows task manager to verify that no instances are active any more

  • As a non-administrative user, open a command line window and enter the following command:

    "c:\Program Files (x86)\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9229

  • In the Windows task manager, in the list which shows the running tasks, add the full command line column and verify that Chrome is running with the correct command line parameter

  • Load the website in question (https://website.local) into Chrome. That website is served by a fully blown Apache stack which runs somewhere else.

  • Turn off the Windows Firewall completely (for testing only of course)

In a Linux system (Debian buster in this case), I do the following:

  • Install VS Code (without Chrome debugger extension, because it is deprecated)

  • In VS Code, create the launch configuration shown below

  • Run the (only) entry from that launch configuration

A few seconds after this action, VS code throws the following error:

Cannot connect to the target at odo.local:9229: Could not connect to debug target at http://odo.local:9229: Could not find any debuggable target.

Please note that odo.local is the FQDN of the Windows PC where Chrome runs.

The following is the complete launch.json with comments and empty lines being the only things which have been removed. Of course, I also have tried every combination of other attributes and values which halfway would make sense, using the IntelliSense popups as a guideline, but nothing worked. In every case, VS Code threw the error mentioned above.

{
    "version": "0.2.0",
    "configurations": [    
        {
            "type": "pwa-chrome",
            "request": "attach",
            "name": "Attach to Chrome on ODO",
            "address": "odo.local",
            "port": 9229,
            "urlFilter": "https://website.local/*"
        }
    ]
}

How do I need to change that launch configuration to make VS Code connect to Chrome on the different PC and start debugging there?

0

There are 0 answers