selenoid: Can not connect to Selenoid container by puppeteer using websocket
Issue overview
I get an error when try to connect to selenoid container via websocket. Error looks like:
Error {
message: 'Protocol error (Target.getBrowserContexts): Target closed.',
}
What steps were done:
- Download specific selenoid image
./cm selenoid download vaniapooh/chrome:71.0-devtools --force
- Configure for downloading chrome 71
./cm selenoid configure --browsers chrome:71.0
- Start Selenoid
- Create a browser session via request:
const { data } = await axios.post(
`http://${selenoidUrl}:4444/wd/hub/session`,
{
"desiredCapabilities":
{
browserName: "chrome",
"selenoid:options": {
sessionTimeout: '3m',
enableVnc: true
}
}
}
);
- Get from response
sessionId
- Try to make connection by
puppeteer
via websocket:
const browser = await puppeteer.connect(
{ browserWSEndpoint: `ws://${selenoidUrl}:4444/devtools/${sessionId}` }
);
At this point a get an error.
Reproducible repository
https://github.com/CrispusDH/puppeteer-ava-selenoid
How to run:
- Firstly, install all dependencies
npm i
- Download Configuration Manager tool
npm run cm:install
- Run test
npm run stest
(in background it will download and setup Selenoid as it needed)
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Comments: 15 (6 by maintainers)
Commits related to this issue
- Migrated /devtools/ API to ReverseProxy (can proxy web sockets in Golang 1.12+) (related to aerokube/selenoid#700) — committed to vania-pooh/selenoid by vania-pooh 5 years ago
Works
Thanks @vania-pooh @BorisOsipov
@CrispusDH your test now seems to work with
aerokube/selenoid:latest
andvaniapooh/chrome:75.0-devtools
as image. Btw, your test is not closing sessions correctly (should dodriver.quit()
on tear down).