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
Connecting to docker chromedp/headless-shell instance via RemoteAllocator #438
Comments
There is also the following comment from a previous issue which leads me to believe what I am trying to do is possible. I can only assume the interface he was talking about was RemoteAllocator. If I am wrong about this please point me in the right direction.
Posted by @mvdan in #244 (comment) |
This is exactly the issue I'm trying to resolve as well. My go process did took this exact approach before the ChromeDP api implementation was changed to used ChromeDP.ctx. Do you have a time frame for this new functionality? |
We haven't started implementing the executor which seamlessly uses Docker, but you should be able to use RemoteAllocator to connect to an existing chrome debugging protocol port/socket. If that doesn't work, please paste your code in this issue and I can try to help debug and fix it. |
Hi @gregtczap... I'm trying to do the same currently in my project. following @mvdan last comment, do you still unable to make the connection to the remote allocator? would like to share your code snippet here if you successfully made it. I would really appreciate 🙏 Thanks |
it's the example https://gist.github.com/wpajqz/45789f7e99df782cca2cb9a926770a00 |
use |
You could use something like the following:
|
Using puppeteer you can launch a chromium based browser and it will produce an output web socket url somethig like "ws://127.0.0.1:8080/devtools/browser/7a732fe0-594a-47d3-a8fa-7d48415954cd".
Later in golang code we can use it like this, `flag.StringVar(&devToolWsUrl, "devtools-ws-url", "ws://127.0.0.1:8080/devtools/browser/7a732fe0-594a-47d3-a8fa-7d48415954cd", "DevTools Websocket URL")
|
I would like to know how to connect to a chromedp/headless-shell docker instance as a remote allocator. I have seen a few comments recommending to run the go binary inside of the chromedp/headless-shell container as a solution, but it has also been implied this is not the only way to connect. Is it possible to have a go process connect to headless-shell through a running docker instance of chromedp/headless-shell but with the go binary running on the host instead of inside the headless-shell container?
The chromedp/headless-shell documentation gives this run command as an example:
docker run -d -p 9222:9222 --rm --name headless-shell chromedp/headless-shell
which I can only assume is given for the purpose of connecting to the instance from outside, is this correct?It seems to me this was the intention of the RemoteAllocator interface. But the problem I am having is that I don't know what
url string
to pass tofunc NewRemoteAllocator(parent context.Context, url string)
. I have tried passing itws://127.0.0.1:9222
but it errors withcould not dial "ws://127.0.0.1:9222": unexpected HTTP response status: 404
. I know the url should probably look something likews://127.0.0.1:9222/devtools/browser/12939166-3db0-49cd-9aaa-56381ef91a7f
but the last portion is dynamic and I do not know how to obtain that url from the docker instance running headless-shell.The text was updated successfully, but these errors were encountered: