I am launching seleniumgrid with mobbrowserproxy in a docker bridged network. The remote driver proxy settings are configured correctly but i cannot connect to the proxy server from the chrome driver. I have looked at all the issues and i cannot find a solution.
Below is the error which shows the driver desired capabilities/options.
selenium-hub | 15:40:24.222 INFO [TestSlot.getNewSession] - Trying to create a new session on test slot {server:CONFIG_UUID=ef95a1c8-8c30-472b-9e5e-323b8a8c9045, seleniumProtocol=WebDriver, browserName=chrome, maxInstances=1, platformName=LINUX, version=74.0.3729.169, applicationName=, platform=LINUX}
chrome_1 | 15:40:24.243 INFO [ActiveSessionFactory.apply] - Capabilities are: {
chrome_1 | "browserName": "chrome",
chrome_1 | "goog:chromeOptions": {
chrome_1 | "args": [
chrome_1 | "--disable-gpu",
chrome_1 | "--headless",
chrome_1 | "--no-sandbox",
chrome_1 | "--whitelisted-ips",
chrome_1 | "--disable-dev-shm-usage",
chrome_1 | "--allow-insecure-localhost",
chrome_1 | "--disable-web-security",
chrome_1 | "--ignore-certificate-errors",
chrome_1 | "--allow-running-insecure-content"
chrome_1 | ],
chrome_1 | "extensions": [
chrome_1 | ]
chrome_1 | },
chrome_1 | "proxy": {
chrome_1 | "httpProxy": "0.0.0.0:9099",
chrome_1 | "proxyType": "manual",
chrome_1 | "sslProxy": "0.0.0.0:9099"
chrome_1 | },
chrome_1 | "version": ""
chrome_1 | }
chrome_1 | 15:40:24.243 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
chrome_1 | Starting ChromeDriver 74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729@{#29}) on port 28080
chrome_1 | Only local connections are allowed.
chrome_1 | Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
chrome_1 | [1589038824.252][SEVERE]: bind() failed: Cannot assign requested address (99)
chrome_1 | 15:40:24.418 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS
chrome_1 | 15:40:24.444 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session 4c42082804845cf9571e6a843a63feca (org.openqa.selenium.chrome.ChromeDriverService)
chrome_1 | 15:40:34.798 INFO [ActiveSessions$1.onStop] - Removing session 4c42082804845cf9571e6a843a63feca (org.openqa.selenium.chrome.ChromeDriverService)
I believe the key point of this stacktrace is right here
chrome_1 | Only local connections are allowed.
chrome_1 | Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
chrome_1 | [1589038824.252][SEVERE]: bind() failed: Cannot assign requested address (99)
To reproduce this error. If you simple launch the containers and login to chromenode and use the chromedriver cli, you should see the same error in the terminal. Again the target of this issue is connecting the proxy container via chromedriver proxy settings.
version: "3"
services:
selenium-hub:
image: selenium/hub:3.141.59-20200409
container_name: selenium-hub
ports:
- "4444:4444"
networks:
- caowebtests
chrome:
image: selenium/node-chrome:3.141.59-oxygen
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
networks:
- caowebtests
expose:
- 9515
firefox:
image: selenium/node-firefox:3.141.59-20200409
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
networks:
- caowebtests
opera:
image: selenium/node-opera:3.141.59-20200409
depends_on:
- selenium-hub
environment:
- HUB_HOST=selenium-hub
- HUB_PORT=4444
networks:
- caowebtests
proxy:
image: spothero/browsermob-proxy:1.0.0
depends_on:
- selenium-hub
networks:
- caowebtests
ports:
- "9090:9090"
links:
- selenium-hub
- firefox
- chrome
- opera
robottests:
container_name: robottests
command: /bin/sleep infinity
depends_on:
- selenium-hub
build: .
volumes:
- ./reports:/cao_ui_tests/reports
networks:
- caowebtests
networks:
caowebtests:
driver: bridge
As you can see in the trace above. the desired capabilities and options are all there. What I am trying to find out is why the chrome driver is getting this error with the proxy settings above.
My test is failing when looking for the first element on the login page. I am not sure if you need the test scripts and the ability to execute the test scripts to try to reproduce this or if this is something that can be pointed out. I can add this repo to github if needed.
*** Settings ***
Library BrowserMobProxy
Library SeleniumLibrary
Library RequestsLibrary
Library Collections
Resource resources${/}base.robot
Resource resources${/}common.robot
Resource resources${/}auth.robot
Suite Setup Setup Test Suite
Test Teardown Close All Browsers
Suite Teardown Test Suite Teardown
*** Variables ***
${BMP_HOST} 0.0.0.0
${BMP_PORT} 9090
${SELENIUM} http://0.0.0.0:4444/wd/hub
${SHOT_NUM} 0
@{TIMINGS}
*** Test Cases ***
Login User
Wait Until Page Loads
Wait Until Page Contains Element ${UI['login']} timeout=10
Submit Credentials %{TEST_USER} %{TEST_PASS}
*** Keywords ***
Setup Test Suite
Load UI Repository ${REPO_PATH}
Connect To Remote Server ${BMP_HOST} ${BMP_PORT}
Set Selenium Implicit Wait 0.2 seconds
Set Selenium Timeout 30 seconds
${prefs}= Evaluate sys.modules['selenium.webdriver'].ChromeOptions() sys, selenium.webdriver
&{caps}= Set Capabilities
Call Method ${prefs} add_argument --disable-gpu
Call Method ${prefs} add_argument --headless
Call Method ${prefs} add_argument --no-sandbox
Call Method ${prefs} add_argument --whitelisted-ips
Call Method ${prefs} add_argument --disable-dev-shm-usage
Call Method ${prefs} add_argument --allow-insecure-localhost
Call Method ${prefs} add_argument --disable-web-security
Call Method ${prefs} add_argument --ignore-certificate-errors
Call Method ${prefs} add_argument --allow-running-insecure-content
Create Webdriver Remote command_executor=${SELENIUM} desired_capabilities=${caps}
options=${prefs}
New Har LoginPage
Go To https://cardatonce.eftsource.com
Test Suite Teardown
Get Har file.har
Close Proxy
Set Capabilities
[Documentation] Set the options for the selenium Driver
${port}= Create Proxy
&{proxy}= Create Dictionary
... proxyType MANUAL
... sslProxy ${BMP_HOST}:${port}
... httpProxy ${BMP_HOST}:${port}
&{caps}= Create Dictionary browserName=chrome platform=ANY proxy=&{proxy}
Log Selenium capabilities: ${caps}
[return] ${caps}
Create Proxy
[Documentation] Get a BMP port for our test
Create Session bmp http://${BMP_HOST}:${BMP_PORT}
${resp}= Get Request bmp /proxy
Should Be Equal As Strings ${resp.status_code} 200
Log BMP Sessions: ${resp.text} [${resp.status_code}]
&{headers}= Create Dictionary Content-Type=application/x-www-form-urlencoded
&{data}= Create Dictionary trustAllServers=True
${resp}= Post Request bmp /proxy data=${data} headers=${headers}
Should Be Equal As Strings ${resp.status_code} 200
Log ${resp.text} [${resp.status_code}]
${port}= Get From Dictionary ${resp.json()} port
Log New BMP port: ${port} [${resp.status_code}]
Set Global Variable ${port}
[return] ${port}
Close Proxy
${resp}= Delete Request bmp /proxy/${port}
Should Be Equal As Strings ${resp.status_code} 200
Log Closed proxy at ${port} [${resp.status_code}]
New Har
[Documentation] Name and initialize a Har
[arguments] ${pagename}
&{data}= Create Dictionary initialPageRef=${pagename}
${resp}= Put Request bmp /proxy/${port}/har params=${data}
#Should Be Equal As Strings ${resp.status_code} 204
Log New Har (${pagename}) [${resp.status_code}]
This is on a MacOs Mojave.
I think the most important part of this script is the variables connecting to the hub and the mob browser proxy containers
${BMP_HOST} 0.0.0.0
${BMP_PORT} 9090
${SELENIUM} http://0.0.0.0:4444/wd/hub
This script just shows you how I am setting the preferences that you already see here in the stacktrace on the chrome node.
chrome_1 | Only local connections are allowed.
chrome_1 | Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
chrome_1 | [1589038824.252][SEVERE]: bind() failed: Cannot assign requested address (99)
These are the issues i have already found online
One
Two - at the bottom of this issue it was resolved with adding, and as you can see above. I have already tried this.
--disable-dev-shm-usage'
Three this guy solved this problem by adding ipv6 to his docker config. But i am using a bridged network in docker compose so i dont see why this option would matter....
I am not sure if this is an issue with chromedriver or docker. To go through a couple of things i have already tried...
馃憢 Hi there! Thank you for creating this issue.
I am the Selenium Assistant Bot 馃, I triage issues in this repository. If I can't do it, I label it to help maintainers identify issues that need triaging.
I am an Open Source project 馃檶, post bugs or ideas here!
鉂楋笍 It seems this issue is not using any of the supported templates
馃挕 Supported issue types are (they start with):
Issue templates help this project to stay in shape, please use them and fill them out completely. By doing that you are helping the project because the community and maintainers can provide prompt feedback, and potentially solve the issue.
If you are asking a question, a better way to address this is:
If you think this is incorrect, please feel free to open a new issue.
Thank you for your contributions.
Same problem in docker.
Also having this issue with standalone configuration. Simplyfied info:
Part of docker-compose for selenium:
selenium:
image: selenium/standalone-chrome:latest
restart: 'no'
container_name: selenium
expose:
- 4444
shm_size: 2g
environment:
- START_XVFB=False
Using it in python tests:
from selenium import webdriver
options = webdriver.ChromeOptions()
options.add_argument('no-sandbox')
options.add_argument('window-size=1980,1800')
options.add_argument('headless')
selenium = webdriver.Remote('http://selenium:4444/wd/hub', options.to_capabilities())
selenium.get(url)
logs:
Attaching to selenium-2070
selenium-2070 | 2020-05-23T00:14:16.407503966Z 2020-05-23 00:14:16,407 INFO Included extra file "/etc/supervisor/conf.d/selenium.conf" during parsing
selenium-2070 | 2020-05-23T00:14:16.408552029Z 2020-05-23 00:14:16,408 INFO supervisord started with pid 8
selenium-2070 | 2020-05-23T00:14:17.410727132Z 2020-05-23 00:14:17,410 INFO spawned: 'xvfb' with pid 11
selenium-2070 | 2020-05-23T00:14:17.412036124Z 2020-05-23 00:14:17,411 INFO spawned: 'selenium-standalone' with pid 12
selenium-2070 | 2020-05-23T00:14:17.416210063Z 2020-05-23 00:14:17,416 INFO success: xvfb entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
selenium-2070 | 2020-05-23T00:14:17.416219848Z 2020-05-23 00:14:17,416 INFO success: selenium-standalone entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
selenium-2070 | 2020-05-23T00:14:17.416297914Z 2020-05-23 00:14:17,416 INFO exited: xvfb (exit status 0; expected)
selenium-2070 | 2020-05-23T00:14:17.598086713Z 00:14:17.597 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
selenium-2070 | 2020-05-23T00:14:17.658495734Z 00:14:17.658 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
selenium-2070 | 2020-05-23T00:14:17.694689254Z 2020-05-23 00:14:17.692:INFO::main: Logging initialized @273ms to org.seleniumhq.jetty9.util.log.StdErrLog
selenium-2070 | 2020-05-23T00:14:17.851489597Z 00:14:17.850 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
selenium-2070 | 2020-05-23T00:14:17.913570524Z 00:14:17.913 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
selenium-2070 | 2020-05-23T00:14:52.192332754Z 00:14:52.191 INFO [ActiveSessionFactory.apply] - Capabilities are: {
selenium-2070 | 2020-05-23T00:14:52.192366514Z "browserName": "chrome",
selenium-2070 | 2020-05-23T00:14:52.192370335Z "goog:chromeOptions": {
selenium-2070 | 2020-05-23T00:14:52.192373075Z "extensions": [
selenium-2070 | 2020-05-23T00:14:52.192375813Z ],
selenium-2070 | 2020-05-23T00:14:52.192378410Z "args": [
selenium-2070 | 2020-05-23T00:14:52.192381072Z "no-sandbox",
selenium-2070 | 2020-05-23T00:14:52.192383731Z "window-size=1980,1800",
selenium-2070 | 2020-05-23T00:14:52.192386400Z "headless"
selenium-2070 | 2020-05-23T00:14:52.192389140Z ]
selenium-2070 | 2020-05-23T00:14:52.192392051Z },
selenium-2070 | 2020-05-23T00:14:52.192394622Z "version": ""
selenium-2070 | 2020-05-23T00:14:52.192397410Z }
selenium-2070 | 2020-05-23T00:14:52.193266467Z 00:14:52.193 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
selenium-2070 | 2020-05-23T00:14:52.205355621Z Starting ChromeDriver 81.0.4044.138 (8c6c7ba89cc9453625af54f11fd83179e23450fa-refs/branch-heads/4044@{#999}) on port 28291
selenium-2070 | 2020-05-23T00:14:52.205376238Z Only local connections are allowed.
selenium-2070 | 2020-05-23T00:14:52.205442889Z Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
selenium-2070 | 2020-05-23T00:14:52.206299526Z [1590192892.206][SEVERE]: bind() failed: Cannot assign requested address (99)
selenium-2070 | 2020-05-23T00:14:52.541943176Z 00:14:52.541 INFO [ProtocolHandshake.createSession] - Detected dialect: W3C
selenium-2070 | 2020-05-23T00:14:52.557612681Z 00:14:52.557 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session b92987067bd687662dcff21485c40a3b (org.openqa.selenium.chrome.ChromeDriverService)
selenium-2070 | 2020-05-23T00:15:36.684681657Z 00:15:36.684 INFO [ActiveSessions$1.onStop] - Removing session b92987067bd687662dcff21485c40a3b (org.openqa.selenium.chrome.ChromeDriverService)
What is the issue? Are tests no passing due to this?
We have seen this message in the logs but this normally doesn鈥檛 affect tests.
What is the issue? Are tests no passing due to this?
We have seen this message in the logs but this normally doesn鈥檛 affect tests.
Django tests are not passing. Thought, that this error could be the cause. Log from one of tests, that locally pass with latest chromedriver:
ERROR: test_update_invoice (backend.invoices.test.test_crud_invoices.CRUDInvoiceTest)
Traceback (most recent call last):
File "/app/backend/crm/test/testing.py", line 140, in setUp
self.do_login(self.login, self.password)
File "/app/backend/crm/test/testing.py", line 147, in do_login
lambda selenium: selenium.find_element_by_class_name('v-application--wrap')
File "/usr/local/lib/python3.7/site-packages/selenium/webdriver/support/wait.py", line 80, in until
raise TimeoutException(message, screen, stacktrace)
selenium.common.exceptions.TimeoutException: Message:
```
whitescreen at screenshots.
It could be a waiting issue or something similar. If the screen was not actually assigned, the browser would not even start and the test would crash when the session is created.
It could be a waiting issue or something similar. If the screen was not actually assigned, the browser would not even start and the test would crash when the session is created.
You were right, the test errors were not related to this message.
Having the same issue with Hub-node configuration in Docker-compose... Is there a way to pass additional options to chromedriver when using selenium/node-chrome image?.. Folks around are suggesting to pass -whitelisted-ips, but I don't see a way how can I do that from this image...
I had the same issue ... I was desperately trying different things (version of selenium, standalone, debug, with hub, manually running driver, replacing capybara, .... lot of nice exercises that helped me to understand what is inside :) )
In my case, I had nearly full disk space allocated in docker for desktop. It did not display any errors that may indicate that this is the root cause. Even building and running some other docker images was OK ...
This is the place where you can check:

Some first aid to remove the largest images from CLI:
docker system df
docker system prune
docker system df
docker system prune --volumes
docker system df
docker images --format "{{.Size}} {{.ID}} {{.Repository}}" | sort -h | tail
# if it is OK to remove those:
# docker images --format "{{.Size}} {{.ID}} {{.Repository}}" | sort -h | tail | cut -f2 -d' ' | xargs docker image rm
docker system df
I see the bind Error as well, but in my env its seems to be benign. the grid and nodes function as expected.