cyrus-and / chrome-har-capturer

Capture HAR files from a Chrome instance
MIT License
535 stars 90 forks source link

Socket hang up #98

Open MT22067 opened 6 months ago

MT22067 commented 6 months ago

Environment

| Component | Version

| Node.js | v12.22.9 | Client (Chrome/Chromium/...) | Google Chrome 123.0.6312.58 | OS running Node.js | Ubuntu 22.04 | OS running the client | Ubuntu 22.04 | chrome-remote-interface | 0.31.3

Is the client running in a container? NO

Description

I was trying to run the following the set of commands (basically to capture HAR file from android) chrome (1) adb shell am start -n com.android.chrome/com.google.android.apps.chrome.Main (2) adb forward tcp:9222 localabstract:chrome_devtools_remote (3) chrome-har-capturer --force --port 9222 -o my.har http://www.example.com Issue received: Socket hang up How to solve this?

cyrus-and commented 6 months ago

Are you able at point 3 to run:

curl -i http://127.0.0.1:9222/json/list

If not, there's some TCP connection issue with your phone.

MT22067 commented 6 months ago

Nope, I am not able to. Any help on how to proceed about it?

MT22067 commented 6 months ago

I did packet capture and could see a few ports connected to 9222 constantly. (exchanging keep-alive messages) I guess forwarding should have worked fine. are you saying that I should capture packets on the mobile device interface?

cyrus-and commented 5 months ago

So the reason is this:

$ chrome-remote-interface inspect -l -w ws://127.0.0.1:9222/devtools/browser
>>> Target.createBrowserContext()
Uncaught ProtocolError: Failed to create browser context.
    at /Users/cyrus/Dropbox/dev/chrome-remote-interface/lib/chrome.js:94:35
    at Chrome._handleMessage (/Users/cyrus/Dropbox/dev/chrome-remote-interface/lib/chrome.js:272:17) {
  request: {
    method: 'Target.createBrowserContext',
    params: undefined,
    sessionId: undefined
  },
  response: { code: -32000, message: 'Failed to create browser context.' }
}

I have no idea why this fails on Chrome for Android, in any case this issue concerns chrome-har-capturer, not this repo.