Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is Chrome /json/version feature deprecated?

I used to debug Chrome with PuppeteerSharp. For that, I run Chrome with command:

"C:\Program Files\Google\Chrome\Application\chrome.exe" --remote-debugging-port=9222 --profile-directory="Default"

Then I wait Chrome t start and make GET request to http://127.0.0.1:9222/json/version to get webSocketDebuggerUrl value, thich I pass to

_browser = await Puppeteer.ConnectAsync(new() 
{ 
    BrowserWSEndpoint = webSocketDebuggerUrl, // value got from Chrome /json/version
});

And that works fine for a year until today. Now if I request http://127.0.0.1:9222/json/version, it gives me ERR_CONNECTION_REFUSED

What I tried is to

  • restart Chrome - no effect
  • restart PC - no effect
  • change port from 9222 to 9223 - no effect
  • enable inbound rule for port 9222 - no effect

The Chrome version I got is 136.0.7103.49 (Official Build) (64-bit) - latest at the moment

Then I push my other PC, which got at moment Chrome 134...., started Chrome with --remote-debugging-port=9222 and it works. Then I decided to update chrome to latest and it breaks...

So my question is did something changed for chrome remote debugging in latest releases? How now should I start Chrome to debug, how should I get webSocketDebuggerUrl value? Or most likely there is some new settings had to be set to allow get that value

Some similar struggles from before

  • here on SO 3 years ago with no answer
  • at reddit 2 years ago, checked whole chrome://inspect/, but didn't found any webSocketDebuggerUrl

Here is also different approach to gain that value, but it looks way too comlex

Have to mention it also not available from chrome://version/

I have found a workaround, but not a solution:

  • find and fownload appropriate Chrome offline installer of version you are OK (134 in my case). Mine one is from igetintopc.com, looks like working one, not sure about side effects btw, mention them as it quite hard to find proper offline installer
  • delete your Chrome via Windows Installed Apps tool, but be sure not to check delete browser history checkbox! At least unless you want to
  • then install your desired Chrome via offline installer
  • be sure not to open Chrome's ... / Help / About Google Chrome! Just opening it will trigger Chrome auto-update, which cannot be cancelled neither turned off in my case. If you did so, repeat re-installation process.
like image 443
bankangle Avatar asked Oct 26 '25 04:10

bankangle


2 Answers

Cause

Back in Mar. '25, an article was posted on Chrome for Developers, stating Google would disable Chrome DevTools Protocol connections for the default data directory, starting from Chrome 136.

As of now, there are 3 alternative solutions/workarounds at our disposal as follows:

Option 1

Use other Chromium-based browsers such as Edge and Opera, which I, for one, didn't find too hot personally.

Option 2

Use Chrome for Testing, which is spared from the above breaking change for now. This policy, however, is at the mercy and whim of Google and may or may not change further down the road.

Option 3

In the following instruction, make sure to customize your user name and %USERPROFILE%\AppData\Chrome for CDP to your needs/liking.

  1. Close all Chrome windows and use Task Manager to make sure no Chrome processes are running.
  2. Copy or move the %LOCALAPPDATA%\Google\Chrome\User Data folder to another location with no possible permission issues, e.g., %USERPROFILE%\AppData\Chrome for CDP (or C:\Users\your user name\AppData\Local\Google\Chrome).
  3. Right-click and access the Properties of all Chrome links, esp. the one on your taskbar, to change the Target command line to, e.g., %ProgramW6432%\Google\Chrome\Application\chrome.exe --user-data-dir="%USERPROFILE%\AppData\Chrome for CDP\User Data" --remote-debugging-port=9222.

To ensure this custom profile be used when opening .url files:

  1. Press Win+R to run regedit, navigate to the HKEY_CLASSES_ROOT\ChromeHTML\shell\open\command path and export the Default data to a file as a backup.
  2. Change the Default data to, e.g., "C:\Program Files\Google\Chrome\Application\chrome.exe" --user-data-dir="C:\Users\your user name\AppData\Chrome for CDP\User Data" --remote-debugging-port=9222 --single-argument %1. Note that the percent notation for paths (environment variable expansion) won't work here.
  3. All done and you're back to business as usual!

Naturally, you'll have to sign in to websites again. FWIW, I went with this Option 3.

like image 173
johnlee Avatar answered Oct 28 '25 00:10

johnlee


TLDR

  1. Add --user-data-dir=XXX into your usual command
    e.g. --user-data-dir=remote-debug-profile

  2. Viola - Chrome in debug mode will run like usual
    But your folder will have a new folder XXX & git will record 2K+ new files

    e.g. ./remote-debug-profile

  3. Update your .gitignore with XXX

    e.g. remote-debug-profile in .gitignore

Detailed explanation

As @johnlee & @Mini elephant point out:

Back in Mar. '25, an article was posted on Chrome for Developers, stating Google would disable Chrome DevTools Protocol connections for the default data directory, starting from Chrome 136.

Further reading down the blog:

For developers who need to debug Chrome (for example, from VSCode), the instructions already specify use of a custom user data dir and we continue to recommend this approach to isolate any debugging from any real profiles.

Pointing to this Browser Debugging documentation:

edge.exe --remote-debugging-port=9222 --user-data-dir=remote-debug-profile

Setting the --remote-debugging-port tells the browser to listen on that port for a debug connection. Setting a separate --user-data-dir forces a new instance of the browser to be opened; if this flag isn't given, then the command will open a new window of any running browser and not enter debug mode.

Findings:

  • Attackers has been increasingly using Chrome Remote Debugging to perform attacks & extract cookies

  • Because of this security issues, Chrome Remote Debugging will change the following from Chrome 136

1 - Chrome Remote Debugging cannot remotely debug any real user profile & default Chrome data directory

Flag --remote-debugging-port & --remote-debugging-pipe will be ignored silently & Chrome will not enter debug mode if

  1. No --user-data-dir is provided
    (explain in below)

Regardless of the profile choice:

  1. Any existing user profile flag is given, e.g. --profile-directory=Profile\ 5

  2. No profile is specified, that user can select which user profile to launch with

2 - Chrome Remote Debugging can only remotely debug non-standard, custom user profile & data directory

Chrome will only enter debug mode if --user-data-dir is provided

# MacOS zsh
/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome \
    --remote-debugging-port=9222 \
    --profile-directory=Profile\ 5 \
    --user-data-dir=remote-debug-profile
  • Open chrome://version/ in the new Chrome Remote Debugging browser, you'll notice:

    Executable Path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

    Profile Path /Users/MY_ACCOUNT/YOUR_PWD/remote-debug-profile/Profile 5

  • ... which are completely separated from the default Chrome data directory with existing real user data:

    Executable Path /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

    Profile Path /Users/MY_ACCOUNT/Library/Application Support/Google/Chrome/Profile 5

Tested in MacOS, we have the following findings:

  1. --profile-directory

    Flag --profile-directory=Profile\ 5 is not pointing to the existing Chrome user profile 5, but to the new non-standard data directory

  2. --remote-debugging-port & --user-data-dir

    Chrome will only enter debug mode if both of the flags are present

    --remote-debugging-port=9222 launch Chrome remote debugging in port 9222
    --user-data-dir=remote-debug-profile will create a brand new non-standard Chrome user profile & data directory in your working directory

From here, your can perform your usual gmail/Google login, account login for persistent cookies, debugging, scraping, etc...

Just remember to always launch it in the same directory

like image 30
lung2008 Avatar answered Oct 28 '25 00:10

lung2008