X11vnc inside Docker container takes too long to connect

Hello,

I’m using selenoid and selenoid-ui on my Rocky Linux 9 server, everything looks OK, docker logs of selenoid, selenoid ui, selenoid/chrome container when started but when I create selenoid/chrome session it takes several minutes to display the session UI on selenoid UI

Basically, vnc inside docker container is on the 100% even if I maxed it out with resources, and question is - are there any privileges/firewall configuration/security configuration I should set in order to speed up vnc connecting?

and after that, after 3-5 minutes, session UI is displayed.

While waiting for the VNC connection, I inspected selenoid/chrome container and the CPU usage was on 100% by the x11vnc:

As soon as session UI is displayed, CPU usage drops to the normal (not 100%)

This is the case on Rocky Linux 9 server but not on Ubuntu, tried different selenoid configurations but wasn’t successful…

Configuration I’m using now:

{
    "chrome": {
        "default": "127.0",
        "versions": {
            "127.0": {
                "image": "selenoid/chrome:127.0",
                "port": "4444",
                "path": "/",
                "tmpfs": {
                    "/tmp": "size=512m"
                },
	        "env": ["ENABLE_VNC=true", "SCREEN_WIDTH=1920", "SCREEN_HEIGHT=1080", "SCREEN_DEPTH=24"],
                "shmSize" : 268435456,
                "mem": "512m",
		"cpu": "4.0"
            }
            
        }
    }
}

Selenoid logs:

2024/09/04 12:31:19 [-] [NEW_REQUEST] [unknown] [192.168.0.144]
2024/09/04 12:31:19 [-] [NEW_REQUEST_ACCEPTED] [unknown] [192.168.0.144]
2024/09/04 12:31:19 [69] [LOCATING_SERVICE] [chrome] [127.0]
2024/09/04 12:31:19 [69] [USING_DOCKER] [chrome] [127.0]
2024/09/04 12:31:19 [69] [CREATING_CONTAINER] [selenoid/chrome:127.0]
2024/09/04 12:31:19 [69] [STARTING_CONTAINER] [selenoid/chrome:127.0] [7121d69ec5613dcbb8c777a7f6aed6cdfd96f291a073670c394c40476947fdb7]
2024/09/04 12:31:19 [69] [CONTAINER_STARTED] [selenoid/chrome:127.0] [7121d69ec5613dcbb8c777a7f6aed6cdfd96f291a073670c394c40476947fdb7] [0.14s]
2024/09/04 12:31:19 [69] [SERVICE_STARTED] [selenoid/chrome:127.0] [7121d69ec5613dcbb8c777a7f6aed6cdfd96f291a073670c394c40476947fdb7] [0.31s]
2024/09/04 12:31:19 [69] [PROXY_TO] [7121d69ec5613dcbb8c777a7f6aed6cdfd96f291a073670c394c40476947fdb7] [http://172.17.0.4:4444/]
2024/09/04 12:31:19 [69] [SESSION_ATTEMPTED] [http://172.17.0.4:4444/] [1]
2024/09/04 12:31:19 [69] [SESSION_CREATED] [a12187ec49043c3abe46b15cd624a705] [1] [0.84s]
2024/09/04 12:31:22 [72] [CONTAINER_LOGS] [7121d69ec5613dcbb8c777a7f6aed6cdfd96f291a073670c394c40476947fdb7]
2024/09/04 12:31:22 [73] [VNC_ENABLED] [a12187ec49043c3abe46b15cd624a705]
2024/09/04 12:53:06 [-] [NEW_REQUEST] [unknown] [192.168.0.144]
2024/09/04 12:53:06 [-] [NEW_REQUEST_ACCEPTED] [unknown] [192.168.0.144]
2024/09/04 12:53:06 [336] [LOCATING_SERVICE] [chrome] [127.0]
2024/09/04 12:53:06 [336] [USING_DOCKER] [chrome] [127.0]
2024/09/04 12:53:06 [336] [CREATING_CONTAINER] [selenoid/chrome:127.0]
2024/09/04 12:53:07 [336] [STARTING_CONTAINER] [selenoid/chrome:127.0] [ac6d632cc57f6f6e8c59a3c29f3784691a33bc7f70dcf9975ecb7aa2d9184b18]
2024/09/04 12:53:07 [336] [CONTAINER_STARTED] [selenoid/chrome:127.0] [ac6d632cc57f6f6e8c59a3c29f3784691a33bc7f70dcf9975ecb7aa2d9184b18] [0.19s]
2024/09/04 12:53:07 [336] [SERVICE_STARTED] [selenoid/chrome:127.0] [ac6d632cc57f6f6e8c59a3c29f3784691a33bc7f70dcf9975ecb7aa2d9184b18] [0.31s]
2024/09/04 12:53:07 [336] [PROXY_TO] [ac6d632cc57f6f6e8c59a3c29f3784691a33bc7f70dcf9975ecb7aa2d9184b18] [http://172.17.0.5:4444/]
2024/09/04 12:53:07 [336] [SESSION_ATTEMPTED] [http://172.17.0.5:4444/] [1]
2024/09/04 12:53:07 [336] [SESSION_CREATED] [b01d05103c20fd08eea5287b37517f30] [1] [0.90s]
2024/09/04 12:53:11 [339] [CONTAINER_LOGS] [ac6d632cc57f6f6e8c59a3c29f3784691a33bc7f70dcf9975ecb7aa2d9184b18]
2024/09/04 12:53:11 [340] [VNC_ENABLED] [b01d05103c20fd08eea5287b37517f30]

Some of selenoid-ui logs:

2024/09/04 12:26:16 [WS_PROXY] [/ws/logs/a3b0dead0b058a37d056f247997aa8b0] [ws://192.168.0.184:4445/logs/a3b0dead0b058a37d056f247997aa8b0]
2024/09/04 12:26:16 [WS_PROXY] [/ws/vnc/a3b0dead0b058a37d056f247997aa8b0] [ws://192.168.0.184:4445/vnc/a3b0dead0b058a37d056f247997aa8b0]
2024/09/04 12:30:32 [WS_PROXY] [/vnc/a3b0dead0b058a37d056f247997aa8b0] [CLOSED]
2024/09/04 12:30:32 [WS_PROXY] [/logs/a3b0dead0b058a37d056f247997aa8b0] [CLOSED]
2024/09/04 12:31:22 [WS_PROXY] [/ws/logs/a12187ec49043c3abe46b15cd624a705] [ws://192.168.0.184:4445/logs/a12187ec49043c3abe46b15cd624a705]
2024/09/04 12:31:22 [WS_PROXY] [/ws/vnc/a12187ec49043c3abe46b15cd624a705] [ws://192.168.0.184:4445/vnc/a12187ec49043c3abe46b15cd624a705]
2024/09/04 12:53:04 Client added. 4 registered clients
2024/09/04 12:53:11 [WS_PROXY] [/ws/logs/b01d05103c20fd08eea5287b37517f30] [ws://192.168.0.184:4445/logs/b01d05103c20fd08eea5287b37517f30]
2024/09/04 12:53:11 [WS_PROXY] [/ws/vnc/b01d05103c20fd08eea5287b37517f30] [ws://192.168.0.184:4445/vnc/b01d05103c20fd08eea5287b37517f30]

chrome container logs:

19
2024/09/04 12:31:19 [INIT] [Listening on :7070]
Waiting X server...
Logging to: /dev/null
Waiting X server...
Starting ChromeDriver 127.0.6533.72 (9755e24ca85aa18ffa16c743f660a3d914902775-refs/branch-heads/6533@{#1760}) on port 4444
All remote connections are allowed. Use an allowlist instead!
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.

 --- x11vnc loop: 1 ---

 --- x11vnc loop: waiting for: 175

PORT=5900

Sounds like Selenoid needs debuggiing, probably would be best for you to ask the Selenoid community for help on this.

From their FAQ

VNC is consuming all my container CPU

On RedHat-based distributions you should set LimitNOFILE=1048576 for containerd.service

1 Like

Thanks for the reply, I did, got nothing there. Thanks anyway.

Hello, thanks for the reply, just tried this, still nothing, will investigate more that way. Thanks a lot!

The FAQ suggestion didn’t make sense to me, but it’s strange they’ve got an entry for this exact issue.

Yeah, by their documentation, that should be the solution on red hats, but also got this answer/solution on selenoid github:

this is a known CentOS \ RedHat specific issue related to their kernel \ security settings. Switching to another distribution should fix this.

so I ended up switching to Ubuntu and solved it like that…

You could have potentially used the kernel from elrepo and installed kernel-mt or kernel-lt which would give a 6.x kernel and probably resolve the problem as well if the RHEL kernel is crippled slightly. The elrepo one should work. Obviously it’s not official RHEL/Rocky kernel at this point, but that shouldn’t be a major problem.