-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
Unable to connect Lighthouse to a remote browser #11931
Comments
Have you already tried the below? let options = {
hostname: MOON_HOST,
port: MOON_PORT,
// ...
} I can't imagine any other variation working successfully, so I'd start there :) |
It's a little hard to tell from the code you have here, but if Chrome is being launched with |
Ah whoops, I missed that the local connection was working but the remote one wasn't. What @patrickhulce said :) |
Ah, so Moon isn't actually a remote browser. The short answer is you can't do this yet without writing a custom browser connection class that looks like https://github.com/GoogleChrome/lighthouse/blob/master/lighthouse-core/gather/connections/cri.js#L83 (or you implementing some proxy layer to translate Moon). Lighthouse is written to communicate with Chrome and not a generic browser or WebDriver API. #11313 will make this possible to just use your puppeteer page, but for now it's fairly custom. |
Hey @patrickhulce I have a question regarding remote browser usage. I made this very small proof of concept using Lighthouse and browserless.io Chrome container and is working. It's as easier as this: const puppeteer = require('puppeteer-core')
const lighthouse = require('lighthouse');
(async () => {
try {
const urlList = ['https://panor.am/places/', 'https://panor.am/', 'https://d13z.dev', 'https://subito.it/']
for (const url of urlList) {
const browser = await puppeteer.connect({
browserWSEndpoint: 'ws://localhost:3000'
});
console.log(url)
const {lhr} = await lighthouse(url, {
port: (new URL(browser.wsEndpoint())).port,
output: 'json',
logLevel: 'silent',
});
console.log(`Lighthouse scores: ${Object.values(lhr.categories).map(c => c.score).join(', ')}`);
await browser.close();
await new Promise((resolve) => setTimeout(() => resolve(), 3000))
}
} catch (error) {
console.error(error)
}
})() Now I'm wondering about the My question is:
If this function is benchmarking the NodeJS application and this is different from where the browser is, we could have a misalignment in the benchmarks, because we are not benchmarking what is important - the browser - but instead the application. |
It's being executed in the browser wherever the page is being loaded. lighthouse/lighthouse-core/gather/driver.js Lines 193 to 199 in 5c32e64
|
Great! Thanks @patrickhulce , this means that the But what if I run that function manually? Would then be the |
Issue: unable to connect Lighthouse to a remote browser.
Description:
I'm trying to connect Lighthouse to a remote chromium or chrome.
While Playwright and Puppeteer can successfully connect to it, Lighthouse is returning a connection error:
I've also tried different lighthouse hostnames and ports:
I had similar error, eg:
Lighthouse is connecting only on local browser, eg:
const browser = await playwright.chromium.launch({ args: ['--remote-debugging-port=9222'], });
I think I'm missing some step.
How do I properly connect Lighthouse to a remote browser?
Thanks in advance.
Check the code
The text was updated successfully, but these errors were encountered: