Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new error after update #288

Closed
p3x-robot opened this issue Oct 20, 2017 · 6 comments
Closed

new error after update #288

p3x-robot opened this issue Oct 20, 2017 · 6 comments

Comments

@p3x-robot
Copy link

Component Version
Operating system Linux workstation 4.8.0-58-generic #63~16.04.1-Ubuntu SMP Mon Jun 26 18:08:51 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux
Node.js 8.7
Chrome/Chromium/... Google Chrome 62.0.3202.62 unknown
chrome-remote-interface 0.25.2

Is Chrome running in a container? YES / NO

Ciao!

How are you?
I just updated I get this error, is there a change?

2017-10-20 23:05:10 unhandledRejection Error: unexpected server response (404)
    at ClientRequest._req.on (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-server/node_modules/ws/lib/WebSocket.js:656:26)
    at emitOne (events.js:115:13)
    at ClientRequest.emit (events.js:210:7)
    at HTTPParser.parserOnIncomingClient (_http_client.js:549:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:116:23)
    at Socket.socketOnData (_http_client.js:438:20)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at addChunk (_stream_readable.js:264:12)
    at readableAddChunk (_stream_readable.js:251:11)
    at Socket.Readable.push (_stream_readable.js:209:10)
    at TCP.onread (net.js:587:20)
@p3x-robot
Copy link
Author

I get this stdeerr:

DevTools listening on ws://127.0.0.1:37844/devtools/browser/b37d8670-129e-4769-a7b6-2dd075f12fa5

@p3x-robot
Copy link
Author

[2017/10/20 23:12:28.237] [INFO]  [SINGLETON] [PID: 8198] [CORE] [SERVICE] [CHROME] start chrome now running found
[2017/10/20 23:12:28.259] [ERROR] [SINGLETON] [PID: 8198] Error: unexpected server response (404)
    at ClientRequest._req.on (/home/patrikx3/Projects/patrikx3/corifeus/corifeus-server/node_modules/ws/lib/WebSocket.js:656:26)
    at emitOne (events.js:115:13)
    at ClientRequest.emit (events.js:210:7)
    at HTTPParser.parserOnIncomingClient (_http_client.js:549:21)
    at HTTPParser.parserOnHeadersComplete (_http_common.js:116:23)
    at Socket.socketOnData (_http_client.js:438:20)
    at emitOne (events.js:115:13)
    at Socket.emit (events.js:210:7)
    at addChunk (_stream_readable.js:264:12)
    at readableAddChunk (_stream_readable.js:251:11)
    at Socket.Readable.push (_stream_readable.js:209:10)
    at TCP.onread (net.js:587:20)

@cyrus-and
Copy link
Owner

Are you using the browser target ws://127.0.0.1:9222/devtools/browser URL explicitly in your code? If that's the case, you should use the one printed on stderr since Chrome 62. You can fetch it programmatically from CDP.Version(), see an example here.

Otherwise please try to provide a minimal example that reproduces this issue.

@p3x-robot
Copy link
Author

p3x-robot commented Oct 21, 2017

Ciao!

How are you?

I was abble to fix it, but it is weird that I have to extract the target in stdeerr which outputs DevTools listening on ws://127.0.0.1:33370/devtools/browser/056f3a21-144c-49c8-95c1-9498c9f39fca.

Isn't there are prettier solution then stdeeerr to get the target? (The devtools url.)

run = execFile('/opt/google/chrome/chrome', [`--remote-debugging-port=${port}`, '--headless', '--disable-gpu', '--enable-logging', /** '--v=1', **/ '--log-level=5', `--user-data-dir=${cacheDir}`, `--user-agent="${agent}"`, 'about:blank'], (err, stdout, stderr) => {
                if (err) {
                    mainRejecter(err)
                }
            });
            run.stdout.on('data', (data) => {
                console.debug(consolePrefix, 'stdout', data);
            });
            run.stderr.on('data', (data) => {
                data = data.trim();
                const devToolsUrlStartString = `DevTools listening on `;
                if (data.includes(devToolsUrlStartString )) {
                    chromeTarget = data.substr(devToolsUrlStartString .length)
                } else if (data.includes('Address already in use')) {
                    mainRejecter(new Error(data));
                } else {
                    console.warn(consolePrefix, 'stdeerr', data);
                }
            });

As you can see I can find in the stdeerr and now I have a chromeTarget, which I can use like:

          const client = await CDP({
                port: port,
//                target: `ws://localhost:${port}/devtools/browser`
                target: chromeTarget,
            });

@cyrus-and
Copy link
Owner

Sure it is weird... I never said that you have to parse stderr, did you even read this?

You can fetch it programmatically from CDP.Version(), see an example here.

In particular:

const {webSocketDebuggerUrl} = await CDP.Version({port});

@p3x-robot
Copy link
Author

ahh, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants