aerokube / ggr

A lightweight load balancer used to create big Selenium clusters
https://aerokube.com/ggr/latest/
Apache License 2.0
314 stars 74 forks source link

ggr times out when trying to start a session using selenium standalone server #379

Closed ABSAhmad closed 1 year ago

ABSAhmad commented 1 year ago

Hello,

I followed the README docs to use ggr and put a selenium standalone server running behind it but unfortunately it just hangs and times out at "SESSION_ATTEMPTED".

I have the following files:

/etc/grid-router/quota/test.xml

<qa:browsers xmlns:qa="urn:config.gridrouter.qatools.ru">
<browser name="chrome" defaultVersion="113">
    <version number="113">
        <region name="1">
            <host name="localhost" port="4445" count="1"/>
        </region>
    </version>
</browser>
</qa:browsers>

selenium standalone running:

root@localhost:~# java -jar selenium-server-4.10.0.jar standalone --port 4445
18:26:27.999 INFO [LogManager$RootLogger.log] - Using the system default encoding
18:26:28.004 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
18:26:29.030 INFO [NodeOptions.getSessionFactories] - Detected 2 available processors
18:26:29.041 INFO [NodeOptions.discoverDrivers] - Driver(s) already present on the host: 1
18:26:29.083 INFO [NodeOptions.report] - Adding Chrome for {"browserName": "chrome","goog:chromeOptions": {"args": ["--remote-allow-origins=*"]},"platformName": "linux"} 2 times (Host)
18:26:29.125 INFO [Node.<init>] - Binding additional locator mechanisms: relative
18:26:29.173 INFO [GridModel.setAvailability] - Switching Node 4308e7e3-a20b-4ed3-b04f-a36817155ac1 (uri: http://172.17.0.1:4445) from DOWN to UP
18:26:29.174 INFO [LocalDistributor.add] - Added node 4308e7e3-a20b-4ed3-b04f-a36817155ac1 at http://172.17.0.1:4445. Health check every 120s
18:26:29.442 INFO [Standalone.execute] - Started Selenium Standalone 4.10.0 (revision c14d967899): http://172.17.0.1:4445

Docker run command for ggr (linux host)

docker run -d --name ggr -v /etc/grid-router/:/etc/grid-router:ro --net host aerokube/ggr:latest-release

ggr logs:

2023/06/12 18:26:36 [2] [0.00s] [SESSION_ATTEMPTED] [test] [127.0.0.1] [chrome-113-ANY] [localhost:4445] [-] [1] [-]
2023/06/12 18:29:36 [2] [180.00s] [CLIENT_DISCONNECTED] [test] [127.0.0.1] [chrome-113-ANY] [localhost:4445] [-] [1] [-]

Exception:

Curl error thrown for http POST to /session with params: {"capabilities":{"firstMatch":[{"browserName":"chrome","goog:chromeOptions":{"args":["--start-maximized","--start-fullscreen","--headless=new","--no-sandbox","--disable-dev-shm-usage","--ignore-certificate-errors"]}}]},"desiredCapabilities":{"browserName":"chrome","platform":"ANY","chromeOptions":{"args":["--start-maximized","--start-fullscreen","--headless=new","--no-sandbox","--disable-dev-shm-usage","--ignore-certificate-errors"]}}}

I'm using php-webdriver to start the instance with the endpoint being "http://test:test@localhost:4444/wd/hub" (yes I set the ggr user and password both to "test")

If I point my script to the port :4445 (selenium standalone) it works just fine. If I point it to ggr, it logs "SESSION_ATTEMPTED", selenium grid then shows something in the queue (with nothing running) and keeps it there until it times out after 180 seconds.

I can also re-produce the same behaviour with a curl command:

curl --data '{"capabilities": {"alwaysMatch": {"browserName": "chrome"}}}' http://test:test@localhost:4444/wd/hub/session

Selenium UI:

image image

Does anyone have an idea how to fix it?

vania-pooh commented 1 year ago

@ABSAhmad you are using localhost:4445 in Ggr config. Ggr is running in container so localhost inside container is not the same host as localhost outside of container. Try to use Selenium container name or docker0 network interface IP address instead.

ABSAhmad commented 1 year ago

Hey @vania-pooh,

first of all thanks for the fast reply! :)

I'm actually running selenium grid on the host machine without a docker container and ggr has --net host, so it actually access the correct localhost which I tested by using /bin/sh to get into the ggr container, installed curl and I can access the grid instance just fine.

I'm currently on mobile but will add more information when I'm back at home in a few hours.

ABSAhmad commented 1 year ago

Okay so it appears that the issue was related to the chrome version not being explicitly set in the selenium grid. I've now set it manually to 113 and it works now.

Here is the selenium config for reference, should anyone else run into this.

[server]
port = 4445

[node]
detect-drivers = false
drivers = ["chrome"]

[[node.driver-configuration]]
display-name = "Chrome Stable"
stereotype = "{\"browserName\": \"chrome\", \"browserVersion\": \"113\", \"platformName\": \"linux\"}"
webdriver-executable = '/usr/local/bin/chromedriver'

Thanks anyway @vania-pooh