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

Lambda AWS - Error: connect ECONNREFUSED 127.0.0.1:9222 #335

Open
matheusbento opened this issue Apr 13, 2022 · 6 comments
Open

Lambda AWS - Error: connect ECONNREFUSED 127.0.0.1:9222 #335

matheusbento opened this issue Apr 13, 2022 · 6 comments

Comments

@matheusbento
Copy link

matheusbento commented Apr 13, 2022

Hello guys I'm having the following error when trying to run serverless-chrome on lambda.

`

2022-04-13T13:04:41.496Z 9b8249dc-60ad-560c-a06f-130cac3fd345 INFO @serverless-chrome/lambda: Spawning headless shell

2022-04-13T13:04:41.498Z 9b8249dc-60ad-560c-a06f-130cac3fd345 INFO @serverless-chrome/lambda: ChromeLauncher No debugging port found on port 9222, launching a new Chrome.
2022-04-13T13:04:41.604Z 9b8249dc-60ad-560c-a06f-130cac3fd345 INFO @serverless-chrome/lambda: Launcher Chrome running with pid 24 on port 9222.
2022-04-13T13:04:41.604Z 9b8249dc-60ad-560c-a06f-130cac3fd345 INFO @serverless-chrome/lambda: Waiting for Chrome 0
2022-04-13T13:04:42.106Z 9b8249dc-60ad-560c-a06f-130cac3fd345 INFO @serverless-chrome/lambda: Waiting for Chrome 1
2022-04-13T13:04:42.608Z 9b8249dc-60ad-560c-a06f-130cac3fd345 INFO @serverless-chrome/lambda: Waiting for Chrome 2
2022-04-13T13:04:43.110Z 9b8249dc-60ad-560c-a06f-130cac3fd345 INFO @serverless-chrome/lambda: Waiting for Chrome 3
2022-04-13T13:04:43.611Z 9b8249dc-60ad-560c-a06f-130cac3fd345 INFO @serverless-chrome/lambda: Waiting for Chrome 4
2022-04-13T13:04:44.113Z 9b8249dc-60ad-560c-a06f-130cac3fd345 INFO @serverless-chrome/lambda: Waiting for Chrome 5
2022-04-13T13:04:44.614Z 9b8249dc-60ad-560c-a06f-130cac3fd345 INFO @serverless-chrome/lambda: Waiting for Chrome 6
2022-04-13T13:04:45.116Z 9b8249dc-60ad-560c-a06f-130cac3fd345 INFO @serverless-chrome/lambda: Waiting for Chrome 7
2022-04-13T13:04:45.617Z 9b8249dc-60ad-560c-a06f-130cac3fd345 INFO @serverless-chrome/lambda: Waiting for Chrome 8
2022-04-13T13:04:46.119Z 9b8249dc-60ad-560c-a06f-130cac3fd345 INFO @serverless-chrome/lambda: Waiting for Chrome 9
2022-04-13T13:04:46.621Z 9b8249dc-60ad-560c-a06f-130cac3fd345 INFO @serverless-chrome/lambda: Waiting for Chrome 10
2022-04-13T13:04:46.622Z 9b8249dc-60ad-560c-a06f-130cac3fd345 INFO @serverless-chrome/lambda: Error trying to spawn chrome: Error: connect ECONNREFUSED 127.0.0.1:9222 at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1144:16) { errno: 'ECONNREFUSED', code: 'ECONNREFUSED', syscall: 'connect', address: '127.0.0.1', port: 9222}

`

My code to connect with puppeteer

 this.chrome = await getChrome();
  puppeteer.use(StealthPlugin());
  this.browser = await puppeteer.connect({
    args: ['--no-sandbox'],
    browserWSEndpoint: this.chrome.endpoint,
    dumpio: true,
    headless: this.isHeadLess,
    disableGpu: this.isHeadLess,
    slowmo: 10,
  });

My code to getChrome:

export const getChrome = async () => {
  try {
    const chrome = await launchChrome(
      process.env.APP_DEV == 'prod'
        ? {
            flags: ['--window-size=1280,1696', '--hide-scrollbars'],
          }
        : { chromePath: process.env.PUPPETEER_EXEC_URL },
    );

    console.log({ chrome });
    
    const response = await request
      .get(`${chrome.url}/json/version`)
      .set('Content-Type', 'application/json');

    const endpoint = response.body.webSocketDebuggerUrl;

    return {
      endpoint,
      instance: chrome,
    };
  } catch (e) {
    console.log({ e });
  }
};;`
@matheusbento
Copy link
Author

matheusbento commented Apr 13, 2022

I also had this error:

DevTools listening on ws://127.0.0.1:9222/devtools/browser/b3db09ab-4250-4c63-be21-07eb1eeefa3d
[0413/133945.501862:FATAL:platform_font_skia.cc(97)] Check failed: InitDefaultFont(). Could not find the default font

@jeremyhaile
Copy link

I also hit this error every time I make a request.

@matheusbento
Copy link
Author

@jeremyhaile If you had some progress, share it with me, please. I'm using docker to build my AWS lambda.

@jeremyhaile
Copy link

@matheusbento I haven't found a workaround yet, but if I do I will post it here!

@DiMiTriFrog
Copy link

Any solution?

@matheusbento
Copy link
Author

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

No branches or pull requests

3 participants