RobCherry / docker-chromedriver

Docker container for creating ChromeDriver servers
99 stars 74 forks source link

chromedriver cant bind adress "[SEVERE]: bind() returned an error, errno=99: Cannot assign requested address (99)" #15

Closed XzenTorXz closed 4 years ago

XzenTorXz commented 6 years ago

OS: Ubuntu 16.04.5 LTS Docker: 18.06.0-ce, build 0ffa825

Steps to reproduce: git clone https://github.com/RobCherry/docker-chromedriver docker build -t test. docker run -d --name="test" test docker exec -it testbash chromedriver

Results ins Error: "bind() returned an error, errno=99: Cannot assign requested address (99)" Its also the same result when run as privileged

If I pull the image directly from docker hub it works.

Walt-H commented 6 years ago

Have you installed the very recent Docker updates?

XzenTorXz commented 6 years ago

yes 18.06.0-ce, build 0ffa825

XzenTorXz commented 6 years ago

I also tried with diffrent version of docker. I think its the latest chromedriver 2.40. The error does not appear on 2.39.

generalredneck commented 6 years ago

I suspect this is IP6 related but don't know for sure... maybe an angle to check into?

VeeTeeDev commented 6 years ago

@XzenTorXz
Did you fix it ?

XzenTorXz commented 6 years ago

no i just use version 2.39 for now.

VeeTeeDev commented 6 years ago

I'm running the standalone chrome from selenium (docker) I tried it with an older version, with a 2.39 chrome driver version inside... but it's still not working

XzenTorXz commented 6 years ago

at the moment im running it through a selenium image: selenium/standalone-chrome then i use docker-compose for the connection.

If thats no option: for a working composition you can check out their repo: https://github.com/SeleniumHQ/docker-selenium/ specifically (but not only): https://github.com/SeleniumHQ/docker-selenium/blob/005531112655bb54c4d6217c5a85b1d6ac67dcac/NodeChrome/Dockerfile Edit: but i think you still need to figure out the versions on the creation time :(

VeeTeeDev commented 6 years ago

I'm using 2.42... It's working right now although the error: Error: "bind() returned an error, errno=99: Cannot assign requested address (99)" Is still in my logs.

j03k64 commented 5 years ago

@VeeTeeDev have you tried to EXPOSE 9515 in your Dockerfile to see if that resolves the issue? I was able to get chromedriver (both 2.42 and 2.39) to work on amazonlinux:2018.03 once I exposed the port (it was failing before that; not sure why).

RajAsapu commented 5 years ago

I came across the same issue while running my tests on Jenkins, the reason is the jenkins Slave on which tests are running doesn't have browser(chrome in my case) installed OR If you are using selenium grid , the node got disconnected from hub

geoff-maddock commented 5 years ago

Running into this issue 'selenium/standalone-chrome-debug:3.14.0'.
I'm running a codeception acceptance test, and the test gets back a chrome browser page

This site can't be reached internal.hostname.text refused to connect.

Looking at the error logs in the standalone-chrome-debug container, it returns

17:05:52.942 INFO [ActiveSessionFactory.apply] - Capabilities are: {
  "browserName": "chrome"
}

17:05:52.942 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)

Starting ChromeDriver 2.42.591071 (0b695ff80972cc1a65a5cd643186d2ae582cd4ac) on port 24471

Only local connections are allowed.

[1538499952.961][SEVERE]: bind() returned an error, errno=99: Cannot assign requested address (99)

17:05:53.502 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS

17:05:53.610 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 0bca924d87c379f35fed69fdea2ff4d0 (org.openqa.selenium.chrome.ChromeDriverService)

17:05:54.199 INFO [ActiveSessions$1.onStop] - Removing session 0bca924d87c379f35fed69fdea2ff4d0 (org.openqa.selenium.chrome.ChromeDriverService)
RajAsapu commented 5 years ago

@geoff-maddock : Chrome has to be headless if its not running in your local .Please check it

skudriashev commented 5 years ago

Did anyone manage to solve this issue?

skudriashev commented 5 years ago

The issue was resolved for me by upgrading to the latest chrome:

$ google-chrome --version
Google Chrome 70.0.3538.67 
$ chromedriver --version
ChromeDriver 2.43.600233 (523efee95e3d68b8719b3a1c83051aa63aa6b10d)
from selenium.webdriver import Chrome                                                                                                                                         
from selenium.webdriver import ChromeOptions                                                                                                                                  

options = ChromeOptions()                                                                                                                                                     
options.add_argument('--headless')                                                                                                                                            
options.add_argument('--disable-extensions')                                                                                                                                  
options.add_argument("--no-sandbox")                                                                                                                                          

browser = Chrome(options=options)                                                                                                                                             
browser.get('http://google.com')                                                                                                                                              
browser.title  # >>> 'Google'
browser.quit()   

If you manually start chromedriver do the following (celery does that for you):

$ chromedriver --whitelisted-ips=
Starting ChromeDriver 2.43.600233 (523efee95e3d68b8719b3a1c83051aa63aa6b10d) on port 9515
All remote connections are allowed. Use a whitelist instead!
j03k64 commented 5 years ago

@skudriashev https://github.com/RobCherry/docker-chromedriver/issues/15#issuecomment-425468323 can you see if this works for you?

nathan-wmrln commented 5 years ago

Looks like an IPv6 issue but I'm having trouble getting a working config the documented way. I straced inside the container and came up with this:

294   bind(15, {sa_family=AF_INET6, sin6_port=htons(9515), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_flowinfo=htonl(0), sin6_scope_id=0}, 28 <unfinished ...>
294   <... bind resumed> )              = -1 EADDRNOTAVAIL (Cannot assign requested address)

So, chromedriver appears to be trying to bind the IPv6 loopback address (::1) -- that's not gonna work in a container. I guess it's not a best practice to use docker run --network=host, so chromedriver --whitelisted-ips appears to be the correct solution; it changes the bind address to ::

criley10 commented 5 years ago

@nathan-wmrln your response along with the reference from @TemaMix worked for me

                ChromeOptions options = new ChromeOptions();
                options.AddArgument("--headless");
                options.AddArgument("--whitelisted-ips");
                options.AddArgument("--no-sandbox");
                options.AddArgument("--disable-extensions");
                this.driver = new ChromeDriver(options);

Starting test execution, please wait... Starting ChromeDriver 2.41.578700 (2f1ed5f9343c13f73144538f15c00b370eda6706) on port 33693 Only local connections are allowed.

VGerris commented 5 years ago

I just wanted to add a comment after having chrome headless issues. Somewhere between February and June the chromedriver changed: when switching from 2.46 to 75.x, suddenly when selenium Java libraries were unchanged, the behaviour changed: chrome was not starting in headless mode and thus crashing in docker. I found that selenium-java 3.5.3 works fine with 2.46 of the driver and 3.141.59 works with the 75.x driver. 3.5.3 with 75.x results in the headless option not working. So if you still have issues after using headless and no-sandbox, make sure the versions work together.

RobCherry commented 5 years ago

@VGerris Yeah, ensuring versions work together is kind of a pain. I originally had an automated build that would push new versions every time the debian base image was updated, and I think that may have caused some issues at one point in time. If you want, feel free to try out the "new" headless version I pushed up a couple weeks ago (docker hub, github branch). It is basically the same thing as before but based on debian:stretch instead of jessie and without XVFB and tinywm.

SlavikCA commented 5 years ago

There is a project, which manages Selenium drivers and makes sure they match:
https://github.com/bonigarcia/webdrivermanager

zymotik commented 5 years ago

I was having this issue with my docker compose, fixed by setting the image to one that included ChromeDriver 74 like so:

version: "3"
services:
  selenium-hub:
    image: selenium/hub
    ports:
      - "4444"
  chrome-node:
    # Fix Chrome version to 74, as 75 errors with [SEVERE]: bind() failed: Cannot assign requested address (99)
    image: selenium/node-chrome:3.141.59-oxygen
    depends_on:
      - selenium-hub
    environment:
      - HUB_HOST=selenium-hub
      - HUB_PORT=4444
    ports:
      - "5555"
sebm commented 5 years ago

I had this problem while making my own chromedriver docker image, and was able to fix it by passing the --whitelisted-ips flag to the chromedriver executable.

viniciusd commented 4 years ago

Tried the --whitelisted-ips flag, still getting the severe message.

RobCherry commented 4 years ago

@viniciusd @zymotik @VGerris I pushed up some new tags based on ChromeDriver/Chrome 77 (see this issue). Feel free to test those.

viniciusd commented 4 years ago

Thanks @RobCherry

Tried the --whitelisted-ips flag, still getting the severe message.

It actually worked

RobCherry commented 4 years ago

If things are working I am going to close this issue. Feel free to open a new issue (and reference this one) if there are still problems.

hraynaud commented 4 years ago

@RobCherry for the newbie question. I'm getting this error running my e2e tests in AWS codebuild. Using the gauge as the test runner any idea on how to pass --whitlisted-ips to as a chrome option with gauge?

RobCherry commented 4 years ago

@hraynaud I have not used gauge, but you can pass IPs to the container by creating container the with a CHROMEDRIVER_WHITELISTED_IPS environment variable.

daveclay commented 4 years ago

FYI, doesn't look like CHROMEDRIVER_WHITELISTED_IPS works.

app@d8f47218a8d7:~$ export CHROMEDRIVER_WHITELISTED_IPS=
app@d8f47218a8d7:~$ chromedriver
Starting ChromeDriver 79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/3945@{#614}) on port 9515
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1576304916.634][SEVERE]: bind() failed: Cannot assign requested address (99)
^C
app@d8f47218a8d7:~$ chromedriver --whitelisted-ips=
Starting ChromeDriver 79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/3945@{#614}) on port 9515
All remote connections are allowed. Use a whitelist instead!
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
^C
RobCherry commented 4 years ago

FYI, doesn't look like CHROMEDRIVER_WHITELISTED_IPS works.

app@d8f47218a8d7:~$ export CHROMEDRIVER_WHITELISTED_IPS=
app@d8f47218a8d7:~$ chromedriver
Starting ChromeDriver 79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/3945@{#614}) on port 9515
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1576304916.634][SEVERE]: bind() failed: Cannot assign requested address (99)
^C
app@d8f47218a8d7:~$ chromedriver --whitelisted-ips=
Starting ChromeDriver 79.0.3945.36 (3582db32b33893869b8c1339e8f4d9ed1816f143-refs/branch-heads/3945@{#614}) on port 9515
All remote connections are allowed. Use a whitelist instead!
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
^C

@daveclay the chromedriver bindary does not use that environment variable. It is used by supervisor when it starts up chromedriver (see https://github.com/RobCherry/docker-chromedriver/blob/master/etc/supervisor/conf.d/chromedriver.conf#L2 for where it is used). If you are not using supervisor as your entrypoint (the default behavior of this docker container), then you will need to configure chromedriver some other way.

jmakr0 commented 4 years ago

I just had the exact same problem. In my setup I put shm by mistake to read only and read/write permission fixed it for me; you could also use chrome_options.add_argument('--disable-dev-shm-usage').

PramodKumarYadav commented 4 years ago

The issue was resolved for me by upgrading to the latest chrome:

$ google-chrome --version
Google Chrome 70.0.3538.67 
$ chromedriver --version
ChromeDriver 2.43.600233 (523efee95e3d68b8719b3a1c83051aa63aa6b10d)
from selenium.webdriver import Chrome                                                                                                                                         
from selenium.webdriver import ChromeOptions                                                                                                                                  

options = ChromeOptions()                                                                                                                                                     
options.add_argument('--headless')                                                                                                                                            
options.add_argument('--disable-extensions')                                                                                                                                  
options.add_argument("--no-sandbox")                                                                                                                                          

browser = Chrome(options=options)                                                                                                                                             
browser.get('http://google.com')                                                                                                                                              
browser.title  # >>> 'Google'
browser.quit()   

If you manually start chromedriver do the following (celery does that for you):

$ chromedriver --whitelisted-ips=
Starting ChromeDriver 2.43.600233 (523efee95e3d68b8719b3a1c83051aa63aa6b10d) on port 9515
All remote connections are allowed. Use a whitelist instead!

For me, I got this error when running chrome from docker container. The only option, I have to add was - options.add_argument('--headless') . In java, this can be done as: ChromeOptions options = new ChromeOptions().setHeadless(true); WebDriver driver = new ChromeDriver(options);