无法访问Chrome无头调试

无法访问Chrome无头调试

本文介绍了无法访问Chrome无头调试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Karma和Jasmine的无头服务器上运行角度5单元测试.我正在使用无头的chrome来运行测试.

I am running a angular 5 unit test on a headless server in Karma and Jasmine. I am using chrome headless to run the tests.

-remote-debugging-port = 9223 一起使用时,我无法访问Chrome的调试模式.我尝试在远程Chrome网址中使用 http://35.1.28.84:9223 .

I am not able to access Chrome's debug mode when using with --remote-debugging-port=9223. I tried with http://35.1.28.84:9223 in my remote chrome url.

我确保所有接口都使用 host:'0.0.0.0'进行监听.我确保端口也已打开.

I made sure the all interfaces are listening with host: '0.0.0.0'. I made sure the port was open also.

为什么我不能远程访问chrome的调试器?

How come I am not able to access chrome's debugger remotely?

START:
29 03 2018 15:38:05.480:INFO [karma]: Karma v2.0.0 server started at http://0.0.0.0:9876/
29 03 2018 15:38:05.482:INFO [launcher]: Launching browser MyHeadlessChrome with unlimited concurrency
29 03 2018 15:38:05.497:INFO [launcher]: Starting browser ChromeHeadless
29 03 2018 15:38:18.487:INFO [HeadlessChrome 0.0.0 (Linux 0.0.0)]: Connected on socket pfKmImL3pGU9ibL7AAAA with id 10485493


headless-karma.conf.js


headless-karma.conf.js

module.exports = function(config) {
  config.set({
    host: '0.0.0.0',
    basePath: '',
    frameworks: ['jasmine', '@angular/cli'],
    plugins: [
      require('karma-jasmine'),
      require('karma-mocha-reporter'),
      require('karma-chrome-launcher'),
      require('karma-jasmine-html-reporter'),
      require('@angular/cli/plugins/karma')
    ],
    reporters: ['mocha'],
    port: 9876,  // karma web server port
    colors: true,
    angularCli: {
      environment: 'dev'
    },
    browsers: ['MyHeadlessChrome'],
    customLaunchers: {
      MyHeadlessChrome: {
        base: 'ChromeHeadless',
        flags: [
          '--disable-translate',
          '--disable-extensions',
          '--no-first-run',
          '--disable-background-networking',
          '--remote-debugging-port=9223',
        ]
      }
    },
    autoWatch: false,
    singleRun: true,
    concurrency: Infinity
  });
};


one@work:~/github/MCTS.UI  (dh/headless-unittests)
$ google-chrome --version
Google Chrome 64.0.3282.167
one@work:~/github/MCTS.UI  (dh/headless-unittests)
$ google-chrome-stable --version
Google Chrome 64.0.3282.167

推荐答案

您需要向chrome提供另一个参数:

There is another parameter you need to supply to chrome:

-远程调试地址= 0.0.0.0

--remote-debugging-address=0.0.0.0

使用给定地址而不是默认环回来接受远程调试连接.应与--remote-debugging-port一起使用.请注意,远程调试协议不会执行任何身份验证,因此,将其公开得太多可能会带来安全风险.

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 remote debugging protocol does not perform any authentication, so exposing it too widely can be a security risk.

这篇关于无法访问Chrome无头调试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-26 08:36