Ben
Ben

Reputation: 62454

Selenium - How to configure max sessions

I'm running a single docker container as part of my stack, the image is selenium/standalone-chrome:97.0.4692.99-chromedriver-97.0.4692.71

I'm seeing issues where it's saying there's no more room for sessions, so I'm trying to increase the number of concurrent sessions by configuring SE_OPTS like:

  selenium:
    mem_limit: 3221225472
    image: selenium/standalone-chrome:97.0.4692.99-chromedriver-97.0.4692.71
    environment:
      START_XVFB: 'false'
      SE_OPTS: --max-sessions=5

However then I'm seeing this in the logs:

1/31/2022 7:20:39 AM Appending Selenium options: --max-sessions=5
1/31/2022 7:20:39 AM Setting up SE_NODE_GRID_URL...
1/31/2022 7:20:39 AM Selenium Grid Standalone configuration:
1/31/2022 7:20:39 AM [network]
1/31/2022 7:20:39 AM relax-checks = true
1/31/2022 7:20:39 AM
1/31/2022 7:20:39 AM [node]
1/31/2022 7:20:39 AM session-timeout = "300"
1/31/2022 7:20:39 AM override-max-sessions = false
1/31/2022 7:20:39 AM detect-drivers = false
1/31/2022 7:20:39 AM max-sessions = 1
1/31/2022 7:20:39 AM
1/31/2022 7:20:39 AM [[node.driver-configuration]]
1/31/2022 7:20:39 AM display-name = "chrome"
1/31/2022 7:20:39 AM stereotype = '{"browserName": "chrome", "browserVersion": "97.0", "platformName": "Linux"}'
1/31/2022 7:20:39 AM max-sessions = 1
1/31/2022 7:20:39 AM Starting Selenium Grid Standalone...
1/31/2022 7:20:39 AM Was passed main parameter '--max-sessions=5' but no main parameter was defined in your arg class
2022-01-31 12:20:39,342 INFO exited: selenium-standalone (exit status 0; expected)

So it seems it's clearly not accepting the value that I'm passing correctly. What tweaks do I need to make here to ensure this setting is applied to selenium?

Upvotes: 3

Views: 8288

Answers (1)

Max Daroshchanka
Max Daroshchanka

Reputation: 2978

Try to set SE_NODE_MAX_SESSIONS.

docker-compose.yaml

version: "3"

services:
    selenium:
        mem_limit: 3221225472
        image: selenium/standalone-chrome:97.0.4692.99-chromedriver-97.0.4692.71
        environment:
          - START_XVFB=false
          - SE_NODE_OVERRIDE_MAX_SESSIONS=true
          - SE_NODE_MAX_SESSIONS=5
          - JAVA_OPTS=-XX:ActiveProcessorCount=5
        ports:
          - "4444:4444"

Output:

docker-selenium-1  | 2022-01-31 13:07:04,254 INFO Included extra file "/etc/supervisor/conf.d/selenium.conf" during parsing
docker-selenium-1  | 2022-01-31 13:07:04,257 INFO supervisord started with pid 8
docker-selenium-1  | 2022-01-31 13:07:05,258 INFO spawned: 'xvfb' with pid 10
docker-selenium-1  | 2022-01-31 13:07:05,260 INFO spawned: 'vnc' with pid 11
docker-selenium-1  | 2022-01-31 13:07:05,262 INFO spawned: 'novnc' with pid 12
docker-selenium-1  | 2022-01-31 13:07:05,263 INFO spawned: 'selenium-standalone' with pid 13
docker-selenium-1  | 2022-01-31 13:07:05,265 INFO success: xvfb entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
docker-selenium-1  | 2022-01-31 13:07:05,265 INFO success: vnc entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
docker-selenium-1  | 2022-01-31 13:07:05,265 INFO success: novnc entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
docker-selenium-1  | 2022-01-31 13:07:05,265 INFO success: selenium-standalone entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
docker-selenium-1  | 2022-01-31 13:07:05,266 INFO exited: xvfb (exit status 0; expected)
docker-selenium-1  | 2022-01-31 13:07:05,269 INFO exited: vnc (exit status 0; expected)
docker-selenium-1  | 2022-01-31 13:07:05,271 INFO exited: novnc (exit status 0; expected)
docker-selenium-1  | Setting up SE_NODE_GRID_URL...
docker-selenium-1  | Selenium Grid Standalone configuration:
docker-selenium-1  | [network]
docker-selenium-1  | relax-checks = true
docker-selenium-1  |
docker-selenium-1  | [node]
docker-selenium-1  | session-timeout = "300"
docker-selenium-1  | override-max-sessions = true
docker-selenium-1  | detect-drivers = false
docker-selenium-1  | max-sessions = 5
docker-selenium-1  |
docker-selenium-1  | [[node.driver-configuration]]
docker-selenium-1  | display-name = "chrome"
docker-selenium-1  | stereotype = '{"browserName": "chrome", "browserVersion": "97.0", "platformName": "Linux"}'
docker-selenium-1  | max-sessions = 5
docker-selenium-1  |
docker-selenium-1  | Starting Selenium Grid Standalone...
docker-selenium-1  | 13:07:05.750 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding
docker-selenium-1  | 13:07:05.756 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
docker-selenium-1  | 13:07:06.493 INFO [NodeOptions.getSessionFactories] - Detected 5 available processors
docker-selenium-1  | 13:07:06.498 WARN [NodeOptions.getSessionFactories] - Overriding max recommended number of 5 concurrent sessions. Session stability and reliability might suffer!
docker-selenium-1  | 13:07:06.499 WARN [NodeOptions.getSessionFactories] - One browser session is recommended per available processor. Safari is always limited to 1 session per host.
docker-selenium-1  | 13:07:06.499 WARN [NodeOptions.getSessionFactories] - Overriding this value for Internet Explorer is not recommended. Issues related to parallel testing with Internet Explored won't be accepted.
docker-selenium-1  | 13:07:06.501 WARN [NodeOptions.getSessionFactories] - Double check if enabling 'override-max-sessions' is really needed
docker-selenium-1  | 13:07:06.555 INFO [NodeOptions.report] - Adding chrome for {"browserName": "chrome","browserVersion": "97.0","platformName": "Linux"} 5 times
docker-selenium-1  | 13:07:06.577 INFO [Node.<init>] - Binding additional locator mechanisms: name, id, relative
docker-selenium-1  | 13:07:06.623 INFO [LocalDistributor.add] - Added node 15680789-ea3c-4d17-9aa4-96801b2ce1f1 at http://172.18.0.2:4444. Health check every 120s
docker-selenium-1  | 13:07:06.649 INFO [GridModel.setAvailability] - Switching node 15680789-ea3c-4d17-9aa4-96801b2ce1f1 (uri: http://172.18.0.2:4444) from DOWN to UP
docker-selenium-1  | 13:07:06.797 INFO [Standalone.execute] - Started Selenium Standalone 4.1.2 (revision 9a5a329c5a): http://172.18.0.2:4444

Upvotes: 8

Related Questions