HENNGE / arsenic

Async WebDriver implementation for asyncio and asyncio-compatible frameworks
Other
349 stars 52 forks source link

How to configure Chromedriver to take '--whitelisted-ips=""' to allow remote connections #128

Open phuang07 opened 3 years ago

phuang07 commented 3 years ago

I am running arsenic within docker with chromedriver, but it complains:

docker@75fbccca7ba8:/docs$ python test.py 0 2

Starting ChromeDriver 91.0.4472.19 (1bf021f248676a0b2ab3ee0561d83a59e424c23e-refs/branch-heads/4472@{#288}) on port 53603
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
[1623448645.578][SEVERE]: bind() failed: Cannot assign requested address (99)
ChromeDriver was started successfully.

my code looks like this:

    # try chrome
    service = services.Chromedriver()
    browser = browsers.Chrome(chromeOptions={
        'args': ['--headless', '--disable-gpu', '--whitelisted-ips=""', '--no-sandbox','--disable-dev-shm-usage']
    })

But that doesn't work. Is there a way we can configure the --whitelisted-ips option for the Chromedrive via code?

dimaqq commented 3 years ago

I tried to read https://bugs.chromium.org/p/chromedriver/issues/detail?id=780 but I can't be sure if they mean --whitelisted-ips="" verbatim or --whitelisted-ips="" typed in the shell which ought to result in --whitelisted-ips= passed to chromedriver. Also, that ticket is 6 years old, things could have changed. May I suggest that you try starting chromedriver manually, from another terminal with different values for this flag to see what may actually work?

dimaqq commented 3 years ago

Given this bit:

233         "whitelisted-ips", "comma-separated whitelist of remote IPv4 addresses "
234             "which are allowed to connect to ChromeDriver",

I think that the double-quotes should not be passed to chromedriver. Thus, please try [..., '--whitelisted-ips=', ...] ...