seleniumhq-community / docker-seleniarm

Multi-Arch (arm64/armhf/amd64) Docker images for the Selenium Grid Server
https://hub.docker.com/u/seleniarm
Other
249 stars 26 forks source link

[🐛 Bug]: Connection Refused when trying to connect to Seleniarm container #50

Closed land0r closed 10 months ago

land0r commented 10 months ago

What happened?

While running acceptance tests inside another Docker container, I faced connection issues. The tests could not establish a connection to the Selenium server on port 4444 inside the SeleniARM Docker container, resulting in the following error:

  [Facebook\WebDriver\Exception\Internal\WebDriverCurlException] Curl error thrown for http POST to /session with params: {"capabilities":{"firstMatch":[{"acceptInsecureCerts":true,"goog:chromeOptions":{"args":["--disable-gpu","--user-agent=wp-browser","--ignore-certificate-errors","--headless","--no-sandbox","--disable-dev-shm-usage"]},"browserName":"chrome"}]},"desiredCapabilities":{"acceptInsecureCerts":true,"goog:chromeOptions":{"args":["--disable-gpu","--user-agent=wp-browser","--ignore-certificate-errors","--headless","--no-sandbox","--disable-dev-shm-usage"]},"browserName":"chrome"}}

Failed to connect to host.docker.internal port 4444: Connection refused  

Command used to start Selenium Grid with Docker

docker run --rm -it -p 4444:4444 -p 5900:5900 -p 7900:7900 --shm-size 2g seleniarm/standalone-chromium:latest

Relevant log output

❯ docker run --rm -it -p 4444:4444 -p 5900:5900 -p 7900:7900 --shm-size 2g seleniarm/standalone-chromium:latest
2023-10-23 16:56:23,504 INFO Included extra file "/etc/supervisor/conf.d/selenium.conf" during parsing
2023-10-23 16:56:23,515 INFO RPC interface 'supervisor' initialized
2023-10-23 16:56:23,516 CRIT Server 'unix_http_server' running without any HTTP authentication checking
2023-10-23 16:56:23,516 INFO supervisord started with pid 10
2023-10-23 16:56:24,528 INFO spawned: 'xvfb' with pid 11
2023-10-23 16:56:24,536 INFO spawned: 'vnc' with pid 12
2023-10-23 16:56:24,550 INFO spawned: 'novnc' with pid 14
2023-10-23 16:56:24,553 INFO spawned: 'selenium-standalone' with pid 18
Setting up SE_NODE_GRID_URL...
2023-10-23 16:56:24,571 INFO success: xvfb entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2023-10-23 16:56:24,571 INFO success: vnc entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2023-10-23 16:56:24,571 INFO success: novnc entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2023-10-23 16:56:24,571 INFO success: selenium-standalone entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
find: '/home/seluser/.config/chromium/Crash Reports/pending/': No such file or directory
Selenium Grid Standalone configuration: 
[network]
relax-checks = true

[node]
session-timeout = "300"
override-max-sessions = false
detect-drivers = false
drain-after-session-count = 0
max-sessions = 1

[[node.driver-configuration]]
display-name = "chrome"
stereotype = '{"browserName": "chrome", "browserVersion": "117.0", "platformName": "Linux"}'
max-sessions = 1

Starting Selenium Grid Standalone...
Tracing is disabled
16:56:25.002 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding
16:56:25.006 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
16:56:25.380 INFO [NodeOptions.getSessionFactories] - Detected 5 available processors
16:56:25.404 INFO [NodeOptions.report] - Adding chrome for {"browserName": "chrome","browserVersion": "117.0","platformName": "linux","se:noVncPort": 7900,"se:vncEnabled": true} 1 times (Host)
16:56:25.412 INFO [Node.<init>] - Binding additional locator mechanisms: relative
16:56:25.423 INFO [GridModel.setAvailability] - Switching Node 33a14880-d92a-421e-8f1e-202e37617401 (uri: http://172.17.0.2:4444) from DOWN to UP
16:56:25.423 INFO [LocalDistributor.add] - Added node 33a14880-d92a-421e-8f1e-202e37617401 at http://172.17.0.2:4444. Health check every 120s
16:56:25.511 INFO [Standalone.execute] - Started Selenium Standalone 4.10.0 (revision c14d967899): http://172.17.0.2:4444
16:57:00.952 INFO [LocalDistributor.newSession] - Session request received by the Distributor: 
 [Capabilities {acceptInsecureCerts: true, browserName: chrome, goog:chromeOptions: {args: [--disable-gpu, --user-agent=wp-browser, --ignore-certificate-errors, --headless, --no-sandbox, --disable-dev-shm-usage]}}]
16:57:00.962 INFO [DriverService$Builder.getLogOutput] - Driver logs no longer sent to console by default; https://www.selenium.dev/documentation/webdriver/drivers/service/#setting-log-output
16:57:01.561 INFO [LocalNode.newSession] - Session created by the Node. Id: 45f975c366ceae89f56915603883e3c6, Caps: Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 117.0.5938.62, chrome: {chromedriverVersion: 117.0.5938.62 (25a7172909a4..., userDataDir: /tmp/.org.chromium.Chromium...}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:36039}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: linux, proxy: Proxy(), se:bidiEnabled: false, se:cdp: ws://172.17.0.2:4444/sessio..., se:cdpVersion: 117.0.5938.62, se:vnc: ws://172.17.0.2:4444/sessio..., se:vncEnabled: true, se:vncLocalAddress: ws://172.17.0.2:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}
16:57:01.566 INFO [LocalDistributor.newSession] - Session created by the Distributor. Id: 45f975c366ceae89f56915603883e3c6 
 Caps: Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 117.0.5938.62, chrome: {chromedriverVersion: 117.0.5938.62 (25a7172909a4..., userDataDir: /tmp/.org.chromium.Chromium...}, fedcm:accounts: true, goog:chromeOptions: {debuggerAddress: localhost:36039}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: linux, proxy: Proxy(), se:bidiEnabled: false, se:cdp: ws://172.17.0.2:4444/sessio..., se:cdpVersion: 117.0.5938.62, se:vnc: ws://172.17.0.2:4444/sessio..., se:vncEnabled: true, se:vncLocalAddress: ws://172.17.0.2:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:extension:minPinLength: true, webauthn:extension:prf: true, webauthn:virtualAuthenticators: true}
16:57:07.651 INFO [ProxyNodeWebsockets.createWsEndPoint] - Establishing connection to ws://172.17.0.2:7900
16:57:11.817 WARN [SeleniumSpanExporter$1.lambda$export$3] - {"traceId": "e7dbf5a94e077f23c0cbd6c4c9cd9ab5","eventTime": 1698080231816720838,"eventName": "HTTP request execution complete","attributes": {"http.flavor": 1,"http.handler_class": "org.openqa.selenium.remote.http.Route$PredicatedRoute","http.host": "host.docker.internal:4444","http.method": "POST","http.request_content_length": "46","http.scheme": "HTTP","http.status_code": 500,"http.target": "\u002fsession\u002f45f975c366ceae89f56915603883e3c6\u002furl"}}

16:57:11.863 WARN [SeleniumSpanExporter$1.lambda$export$3] - {"traceId": "a4291b72d264a1ff2109b7051d4694b8","eventTime": 1698080231862600417,"eventName": "HTTP request execution complete","attributes": {"http.flavor": 1,"http.handler_class": "org.openqa.selenium.remote.http.Route$PredicatedRoute","http.host": "host.docker.internal:4444","http.method": "POST","http.request_content_length": "67","http.scheme": "HTTP","http.status_code": 500,"http.target": "\u002fsession\u002f45f975c366ceae89f56915603883e3c6\u002furl"}}

16:57:12.072 INFO [LocalSessionMap.lambda$new$0] - Deleted session from local Session Map, Id: 45f975c366ceae89f56915603883e3c6
16:57:12.075 INFO [GridModel.release] - Releasing slot for session id 45f975c366ceae89f56915603883e3c6
16:57:12.077 INFO [SessionSlot.stop] - Stopping session 45f975c366ceae89f56915603883e3c6
16:57:12.078 WARN [LocalNode.lambda$new$5] - Removing Downloads folder associated with 45f975c366ceae89f56915603883e3c6
16:57:12.078 WARN [LocalNode.lambda$new$6] - Removing Uploads folder associated with 45f975c366ceae89f56915603883e3c6

Operating System

MacBook Apple M1 Pro, MacOS Sonoma 14.0 (23A344)

Docker Selenium version (tag)

4.10.0 (revision c14d967899)

diemol commented 10 months ago

I don't think this is an issue from these images. You need to check why the container you are running with tests cannot connect back to the host. Am I missing something?

land0r commented 10 months ago

@diemol thank you! I will check the config files and docker network with those containers again. And then let you know tomorrow. So, do you think that this is only the reason?

land0r commented 10 months ago

@diemol okay, so the problem was with the docker network. I have to add Seleniarm container to the docker network where we have the nginx container and then modify hosts file for accessing the domain from the nginx container inside the Seleniarm container. You were right, thanks a lot! Sorry for the false alarm, but I didn't find any documentation about that on the main page of the repo

diemol commented 10 months ago

It is tricky to document every single use case. We have examples with docker-compose and others. This issue lays more in the "how to use docker" section.

github-actions[bot] commented 7 months ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.