SeleniumHQ / docker-selenium

Provides a simple way to run Selenium Grid with Chrome, Firefox, and Edge using Docker, making it easier to perform browser automation
http://www.selenium.dev/docker-selenium/
Other
7.97k stars 2.51k forks source link

When I connect node docker on virtual machine 2 to node hub on virtual machine 1 I get an error. #1403

Closed namilkimfree closed 3 years ago

namilkimfree commented 3 years ago

🐛 Bug Report

021-09-22 07:16:20,520 INFO Included extra file "/etc/supervisor/conf.d/selenium-grid-node-docker.conf" during parsing
2021-09-22 07:16:20,522 INFO supervisord started with pid 9
2021-09-22 07:16:21,524 INFO spawned: 'selenium-grid-node-docker' with pid 11
Starting Selenium Grid Node Docker...
2021-09-22 07:16:21,530 INFO success: selenium-grid-node-docker entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
07:16:21.949 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding
07:16:21.954 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
07:16:22.041 INFO [UnboundZmqEventBus.<init>] - Connecting to tcp://172.30.1.31:4442 and tcp://172.30.1.31:4443
07:16:22.122 INFO [UnboundZmqEventBus.<init>] - Sockets created
07:16:23.130 INFO [UnboundZmqEventBus.<init>] - Event bus ready
07:16:23.251 INFO [NodeServer.createHandlers] - Reporting self as: http://172.30.1.58:2375
07:16:23.265 INFO [NodeOptions.getSessionFactories] - Detected 3 available processors
java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.openqa.selenium.grid.Bootstrap.runMain(Bootstrap.java:77)
    at org.openqa.selenium.grid.Bootstrap.main(Bootstrap.java:70)
Caused by: org.openqa.selenium.grid.config.ConfigException: java.lang.reflect.InvocationTargetException
    at org.openqa.selenium.grid.config.MemoizedConfig.getClass(MemoizedConfig.java:115)
    at org.openqa.selenium.grid.node.config.NodeOptions.getNode(NodeOptions.java:102)
    at org.openqa.selenium.grid.node.httpd.NodeServer.createHandlers(NodeServer.java:128)
    at org.openqa.selenium.grid.node.httpd.NodeServer.asServer(NodeServer.java:184)
    at org.openqa.selenium.grid.node.httpd.NodeServer.execute(NodeServer.java:231)
    at org.openqa.selenium.grid.TemplateGridCommand.lambda$configure$4(TemplateGridCommand.java:129)
    at org.openqa.selenium.grid.Main.launch(Main.java:83)
    at org.openqa.selenium.grid.Main.go(Main.java:57)
    at org.openqa.selenium.grid.Main.main(Main.java:42)
    ... 6 more
Caused by: java.lang.reflect.InvocationTargetException
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.base/java.lang.reflect.Method.invoke(Method.java:566)
    at org.openqa.selenium.grid.config.ClassCreation.callCreateMethod(ClassCreation.java:50)
    at org.openqa.selenium.grid.config.MemoizedConfig.lambda$getClass$4(MemoizedConfig.java:100)
    at java.base/java.util.concurrent.ConcurrentHashMap.computeIfAbsent(ConcurrentHashMap.java:1737)
    at org.openqa.selenium.grid.config.MemoizedConfig.getClass(MemoizedConfig.java:95)
    ... 14 more
Caused by: java.io.FileNotFoundException
    at io.netty.channel.unix.Errors.newConnectException0(Errors.java:153)
    at io.netty.channel.unix.Errors.handleConnectErrno(Errors.java:128)
    at io.netty.channel.unix.Socket.connect(Socket.java:304)
    at io.netty.channel.epoll.AbstractEpollChannel.doConnect0(AbstractEpollChannel.java:773)
    at io.netty.channel.epoll.AbstractEpollChannel.doConnect(AbstractEpollChannel.java:758)
    at io.netty.channel.epoll.EpollDomainSocketChannel.doConnect(EpollDomainSocketChannel.java:87)
    at io.netty.channel.epoll.AbstractEpollChannel$AbstractEpollUnsafe.connect(AbstractEpollChannel.java:600)
    at io.netty.channel.DefaultChannelPipeline$HeadContext.connect(DefaultChannelPipeline.java:1342)
    at io.netty.channel.AbstractChannelHandlerContext.invokeConnect(AbstractChannelHandlerContext.java:548)
    at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:533)
    at io.netty.channel.CombinedChannelDuplexHandler$DelegatingChannelHandlerContext.connect(CombinedChannelDuplexHandler.java:495)
    at io.netty.channel.ChannelOutboundHandlerAdapter.connect(ChannelOutboundHandlerAdapter.java:51)
    at io.netty.channel.CombinedChannelDuplexHandler.connect(CombinedChannelDuplexHandler.java:296)
    at io.netty.channel.AbstractChannelHandlerContext.invokeConnect(AbstractChannelHandlerContext.java:548)
    at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:533)
    at io.netty.channel.AbstractChannelHandlerContext.connect(AbstractChannelHandlerContext.java:517)
    at io.netty.channel.DefaultChannelPipeline.connect(DefaultChannelPipeline.java:978)
    at io.netty.channel.AbstractChannel.connect(AbstractChannel.java:265)
    at io.netty.bootstrap.Bootstrap$3.run(Bootstrap.java:250)
    at io.netty.util.concurrent.AbstractEventExecutor.safeExecute(AbstractEventExecutor.java:164)
    at io.netty.util.concurrent.SingleThreadEventExecutor.runAllTasks(SingleThreadEventExecutor.java:469)
    at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:387)
    at io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:986)
    at io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:829)
Exception in thread "Thread-0" java.lang.NullPointerException
    at org.openqa.selenium.grid.node.httpd.NodeServer.lambda$new$0(NodeServer.java:80)
    at java.base/java.lang.Thread.run(Thread.java:829)

To Reproduce

(172.30.1.31) -> selenium-hub

  1. running selenium hub on virtual machine 1 ( docker run -d -p 4442-4444:4442-4444 --name selenium-hub selenium/hub:4.0.0-rc-2-prerelease-20210916)

(172.30.1.60)

  1. Run node docker on virtual machine 2 (docker run -e SE_EVENT_BUS_HOST=172.30.1.31 -e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 -v /NodeDocker/config.toml:/opt/bin/config.toml -v /assets: /opt/selenium/assets selenium/node-docker:4.0.0-rc-2-prerelease-20210916)
/NodeDocker/config.toml

[docker]
# Configs have a mapping between the Docker image to use and the capabilities that need to be matched to
# start a container with the given image.
configs = [
    "selenium/standalone-chrome:4.0.0-rc-1-prerelease-20210916", "{\"browserName\": \"chrome\"}"
]

#url = "http://host.docker.internal:2375"
# Docker imagee used for video recording
video-image = "selenium/video:ffmpeg-4.3.1-20210916"

# Uncomment the following section if you are running the node on a separate VM
# Fill out the placeholders with appropriate values
#[server]
#host = <ip-from-node-machine>
#port = <port-from-node-machine>
[server]
host = "172.30.1.58"
port = "2375

(172.30.1.58)

  1. dynamic docker vm (chrome and video)

Expected behavior

NODE-DOCKER should run normally.

Test script reproducing this issue (when applicable)

  1. VM 1 docker run -d -p 4442-4444:4442-4444 --name selenium-hub selenium/hub:4.0.0-rc-2-prerelease-20210916
  2. VM 2 docker run -e SE_EVENT_BUS_HOST=172.30.1.31 -e SE_EVENT_BUS_PUBLISH_PORT=4442 -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 -v /NodeDocker/config.toml:/opt/bin/config.toml -v /assets:/opt/selenium/assets selenium/node-docker:4.0.0-rc-2-prerelease-20210916

Environment

OS: Ubuntu 20.04.2 LTS (64 bit) Docker-Selenium image version: selenium/node-docker:4.0.0-rc-2-prerelease-20210916 --> Docker version: Docker version 20.10.2, build 20.10.2-0ubuntu1~20.04.3

Docker-Compose version (if applicable): Exact Docker command to start the containers (if using docker-compose, provide the docker-compose file as well):

namilkimfree commented 3 years ago

Execution with Standalone roles success don't have exception.

Do Node dockers and hubs need to be located on the same machine?

docker run --rm --name selenium-docker -p 4444:4444 \ -v NodeDocker/config.toml:/opt/bin/config.toml \ -v /assets:/opt/selenium/assets \ selenium/standalone-docker:4.0.0-rc-2-prerelease-20210916

diemol commented 3 years ago

They can be on different machines. But the exception says that the file was not found, do you have the configuration file on the other VM as well? Also, the config file path used to start Standalone and Node are different.

namilkimfree commented 3 years ago

@diemol

Other virtual machines also have config files.

/NodeDocker/config.toml file and /assets folder

3 virtual machine servers Docker installation complete /Node Docker/config.toml file and /assets folder

Exists.

NodeDocker VM2

Selenium Hub VM1

VM3 (dynamic server)

have /opt/bin/config.toml and /opt/selenium/aseets in other vm. 172.30.1.31(selenium-hub) 172.30.1.60(selenium-node-docker) 172.30.1.58(server to run dynamically)

namilkimfree commented 3 years ago

@diemol Also i didn't use the [server] section of the config.toml file, use to the local url.

The sending registration event occurs. but It is not registered in Selenium hub.

[docker]
# Configs have a mapping between the Docker image to use and the capabilities that need to be matched to
# start a container with the given image.
configs = [
    "selenium/standalone-chrome:4.0.0-rc-2-prerelease-20210923", "{\"browserName\": \"chrome\"}"
]

url = "http://172.17.0.1:2375"
# Docker imagee used for video recording
video-image = "selenium/video:ffmpeg-4.3.1-20210923"

# Uncomment the following section if you are running the node on a separate VM
# Fill out the placeholders with appropriate values
#[server]
#host = <ip-from-node-machine>
#port = <port-from-node-machine>
#[server]
#host = "172.30.1.58"
#port = "2375

node-docker log image

selenium hub log image

moeniebdavids commented 3 years ago

@namilkimfree Any luck?

diemol commented 3 years ago

I just added this text in the README. It boils down to the configuration, here is what I did on my machines:

Machine 1, 192.168.1.12

docker run --rm -p 4442-4444:4442-4444 --name selenium-hub selenium/hub:4.0.0-20211102

Machine 2, 192.168.1.18

TOML config

[docker]
# Configs have a mapping between the Docker image to use and the capabilities that need to be matched to
# start a container with the given image.
configs = [
    "selenium/standalone-chrome:4.0.0-20211102", '{"browserName": "chrome"}'
]

# Use the appropiate url for your Docker daemon
url = "http://host.docker.internal:2375"
# Docker image used for video recording
video-image = "selenium/video:ffmpeg-4.3.1-20211102"

# Uncomment the following section if you are running the node on a separate VM
# Fill out the placeholders with appropriate values
[server]
host = "192.168.1.18"
port = "5555"

Command

docker run -p 5555:5555 -e SE_EVENT_BUS_HOST=192.168.1.12 \
    -e SE_EVENT_BUS_PUBLISH_PORT=4442 \
    -e SE_EVENT_BUS_SUBSCRIBE_PORT=4443 \
    -v ${PWD}/config.toml:/opt/bin/config.toml \
    -v ${PWD}/assets:/opt/selenium/assets \
    selenium/node-docker:4.0.0-20211102

and then I get this logs:

2021-11-03 13:35:21,980 INFO Included extra file "/etc/supervisor/conf.d/selenium-grid-node-docker.conf" during parsing
2021-11-03 13:35:21,982 INFO supervisord started with pid 8
2021-11-03 13:35:22,984 INFO spawned: 'selenium-grid-node-docker' with pid 10
Starting Selenium Grid Node Docker...
2021-11-03 13:35:22,987 INFO success: selenium-grid-node-docker entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
13:35:23.260 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding
13:35:23.265 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
13:35:23.327 INFO [UnboundZmqEventBus.<init>] - Connecting to tcp://192.168.1.12:4442 and tcp://192.168.1.12:4443
13:35:23.359 INFO [UnboundZmqEventBus.<init>] - Sockets created
13:35:24.362 INFO [UnboundZmqEventBus.<init>] - Event bus ready
13:35:24.448 INFO [NodeServer.createHandlers] - Reporting self as: http://192.168.1.18:5555
13:35:24.461 INFO [NodeOptions.getSessionFactories] - Detected 12 available processors
13:35:24.833 INFO [V141Docker.isContainerPresent] - Checking if container is present: 3d4644485698
13:35:24.856 INFO [Docker.getImage] - Obtaining image: selenium/standalone-chrome:4.0.0-20211102
13:35:24.859 INFO [V141Docker.getImage] - Listing local images: Reference{domain='docker.io', name='selenium/standalone-chrome', tag='4.0.0-20211102', digest='null'}
13:35:24.883 INFO [Docker.getImage] - Obtaining image: selenium/video:ffmpeg-4.3.1-20211102
13:35:24.884 INFO [V141Docker.getImage] - Listing local images: Reference{domain='docker.io', name='selenium/video', tag='ffmpeg-4.3.1-20211102', digest='null'}
13:35:24.896 INFO [Docker.getImage] - Obtaining image: selenium/video:ffmpeg-4.3.1-20211102
13:35:24.896 INFO [V141Docker.getImage] - Listing local images: Reference{domain='docker.io', name='selenium/video', tag='ffmpeg-4.3.1-20211102', digest='null'}
13:35:24.911 INFO [Docker.getImage] - Obtaining image: selenium/standalone-chrome:4.0.0-20211102
13:35:24.911 INFO [V141Docker.getImage] - Listing local images: Reference{domain='docker.io', name='selenium/standalone-chrome', tag='4.0.0-20211102', digest='null'}
13:35:24.927 INFO [DockerOptions.lambda$getDockerSessionFactories$1] - Mapping Capabilities {browserName: chrome} to docker image selenium/standalone-chrome:4.0.0-20211102 12 times
13:35:24.940 INFO [Node.<init>] - Binding additional locator mechanisms: name, relative, id
13:35:24.984 INFO [NodeServer$1.start] - Starting registration process for node id 5bb4eca3-113d-4ba9-93a3-e709b1b4a6ca
13:35:24.985 INFO [NodeServer.execute] - Started Selenium node 4.0.0 (revision 3a21814679): http://192.168.1.18:5555
13:35:24.992 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
13:35:25.198 INFO [NodeServer.lambda$createHandlers$2] - Node has been added

Please check the added text to the README and the example provided above. Also, keep in mind that if you are mounting volumes in Linux, you might bump into this.

namilkimfree commented 3 years ago

@diemol thank you .

I tried your guide, The result is success.

thank you best regard

github-actions[bot] commented 2 years 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.