Unable to connect to Hub & Node in Selenium 4.4.0 - selenium

We are getting an the below error try.SeleniumSpanExporter","log-time-local": "2022-09-22T13:07:01.425Z","log-time-utc": "2022-09-22T13:07:01.425Z","method": "lambda$export$4"} 13:07:01.425 DEBUG [LocalDistributor.add] - Exception while adding Node http://10.251.155.85:5555 java.io.UncheckedIOException: java.net.ConnectException: connection timed out: /10.251.155.**:5555
Hub Command: java -jar selenium-server-4.0.0.jar hub
O/P-HUB Output
Node Command: java -jar selenium-server-4.4.0.jar node --hub http://10...**:4444/grid/register [Passing the hub IP]
O/P-
C:\Users\Administrator>java -jar C:\apps\relay\webcluster\selenium-server.jar node --publish-events tcp://10.251.155.74:4442 --subscribe-events tcp://10.251.155.74:4443
07:35:34.313 INFO [LogManager$RootLogger.log] - Using the system default encoding
07:35:34.317 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
07:35:34.481 INFO [UnboundZmqEventBus.<init>] - Connecting to tcp://10.251.155.74:4442 and tcp://10.251.155.74:4443
07:35:34.565 INFO [UnboundZmqEventBus.<init>] - Sockets created
07:35:35.567 INFO [UnboundZmqEventBus.<init>] - Event bus ready
07:35:35.683 INFO [NodeServer.createHandlers] - Reporting self as: http://10.251.155.85:5555
07:35:35.752 INFO [NodeOptions.getSessionFactories] - Detected 4 available processors
07:35:35.783 INFO [NodeOptions.discoverDrivers] - Discovered 2 driver(s)
07:35:35.821 INFO [NodeOptions.report] - Adding Chrome for {"browserName": "chrome"} 4 times
07:35:35.821 INFO [NodeOptions.report] - Adding Firefox for {"browserName": "firefox"} 4 times
07:35:35.868 INFO [Node.<init>] - Binding additional locator mechanisms: relative, name, id
07:35:36.138 INFO [NodeServer$1.start] - Starting registration process for Node http://10.251.155.85:5555
07:35:36.138 INFO [NodeServer.execute] - Started Selenium node 4.4.0 (revision e5c75ed026a): http://10.251.155.85:5555
07:35:36.169 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
07:35:46.186 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
07:35:56.202 INFO [NodeServer$1.lambda$start$1] - Sending registration event...
I also tried with passing java -jar selenium-server-.jar node --publish-events tcp://:8886 --subscribe-events tcp://:8887 still no luck .

Related

Failed to connect Couldn't register this node: Error sending the registration request: Failed to connect while registering SeleniumGrid Node to Hub

Selenium hub is up and running on Windows desktop, set up Windows VM to be node. Node won't register to hub.
Step 1:
Entered command in Windows Desktop:
java -jar selenium-server-standalone-3.14.0.jar -role hub -port 2222
Output:
`11:11:24.171 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.14.0', revision: 'aacccce0'
11:11:24.175 INFO [GridLauncherV3$2.launch] - Launching Selenium Grid hub on port 2222
11:11:25.108:INFO::main: Logging initialized #2242ms to org.seleniumhq.jetty9.util.log.StdErrLog
11:11:26.832 INFO [Hub.start] - Selenium Grid hub is up and running
11:11:26.832 INFO [Hub.start] - Nodes should register to http://172.20.111.25:2222/grid/register/
11:11:26.832 INFO [Hub.start] - Clients should connect to http://172.20.111.25:2222/wd/hub`
Checked the config page on localhost and saw that it was there.
Step 2:
Entered this into the command line in Windows Virtual Machine:
java -jar selenium-server-standalone-3.14.0.jar -role node -hub http://172.20.111.25:2222/grid/register
Output:
10:18:43.108 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.14.0', revision: 'aacccce0'
10:18:43.155 INFO [GridLauncherV3$3.launch] - Launching a Selenium Grid node on port 18004
2019-06-03 10:18:43.676:INFO::main: Logging initialized #1482ms to org.seleniumhq.jetty9.util.log.StdErrLog
10:18:44.108 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 18004
10:18:44.108 INFO [GridLauncherV3$3.launch] - Selenium Grid node is up and ready to register to the hub
10:18:44.280 INFO [SelfRegisteringRemote$1.run] - Starting auto registration thread. Will try to register every 5000 ms.
10:18:44.280 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://172.20.111.25:2222/grid/register
10:19:06.003 INFO [SelfRegisteringRemote$1.run] - Couldn't register this node: Error sending the registration request: Failed to connect to /172.20.111.25:2222
You were almost there. You need to remove the additional forward slash (i.e. /) at the end of the registration uri while registering the Selenium Grid Node and you can use the following steps:
First of all, to start the Selenium Grid Hub on port 2222 you need to issue the following command:
java -jar selenium-server-standalone-3.14.0.jar -role hub -port 2222
You will find the following logs generated:
16:00:50.746 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.14.0', revision: 'aacccce0'
16:00:50.750 INFO [GridLauncherV3$2.launch] - Launching Selenium Grid hub on port 2222
2019-05-31 16:00:51.392:INFO::main: Logging initialized #1151ms to org.seleniumhq.jetty9.util.log.StdErrLog
16:00:52.139 INFO [Hub.start] - Selenium Grid hub is up and running
16:00:52.141 INFO [Hub.start] - Nodes should register to http://192.168.1.125:2222/grid/register/
16:00:52.141 INFO [Hub.start] - Clients should connect to http://192.168.1.125:2222/wd/hub
Now you can access the Selenium Grid Console through the URL:
http://localhost:2222/grid/console
The console will look like:
Now finally to start the Selenium Grid Node you have to issue the following command:
java -jar selenium-server-standalone-3.14.0.jar -role node -hub http://192.168.1.125:2222/grid/register
You will find the following logs generated:
16:04:48.440 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.14.0', revision: 'aacccce0'
16:04:48.470 INFO [GridLauncherV3$3.launch] - Launching a Selenium Grid node onport 7724
2019-05-31 16:04:48.985:INFO::main: Logging initialized #1059ms to org.seleniumhq.jetty9.util.log.StdErrLog
16:04:49.275 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 7724
16:04:49.275 INFO [GridLauncherV3$3.launch] - Selenium Grid node is up and ready to register to the hub
16:04:49.454 INFO [SelfRegisteringRemote$1.run] - Starting auto registration thread. Will try to register every 5000 ms.
16:04:49.454 INFO [SelfRegisteringRemote.registerToHub] - Registering the node to the hub: http://192.168.1.125:2222/grid/register
16:04:50.355 INFO [SelfRegisteringRemote.registerToHub] - The node is registered to the hub and ready to use
I would suggest to go through the steps mentioned below through which I am successfully able to resolve that issue.
Login to other machine and register it as a node.
Ping IP from both the machines to check whether you're on a same network.
Verify that Windows Defender Firewall should be off to ping machine when you're trying on a same network.
In Node Machine , Download standalone jar and paste in some directory and open cmd from that directory .
Verify whether you're able to check URL in Node machine
Ex: URL : http://xx.xx.xx.xx:4444/grid/console
Run the command :
java -Dwebdriver.chrome.driver="C:\chromedriver.exe" -jar selenium-server-standalone-3.141.59.jar -role webdriver -hub http://xx.xx.xx.xx:4444/grid/register -port 5566
Okay, I believe I fixed this error.
So I started the hub from my desktop: 172.17.248.33
and then I tried to connect the node from my virtual machine: 173.248.137.73 back to my desktop 172.17.248.33.
I knew beforehand that when I started the hub from my desktop and then ran a node on my desktop it would connect.
However, I was under the impression I could start the hub in my desktop 172.17.248.33 and then have my VM node 173.248.137.73 connected to the hub desktop. I am guessing this is not possible with Selenium.
Once I started the hub from my virtual machine and initiated the node command from the same machine, it worked.

How to fix this Selenium Error: bind() failed: Cannot assign requested address (99)

I've installed the latest version of selenium via Docker:
docker run -d -p 4444:4444 -v /dev/shm:/dev/shm selenium/standalone-chrome:latest
and then ran this in my python console:
from selenium import webdriver
from selenium.webdriver.common.desired_capabilities import DesiredCapabilities
driver = webdriver.Remote("http://127.0.0.1:4444/wd/hub", DesiredCapabilities.CHROME)
and finally checked the docker logs:
2019-04-24 19:09:26,880 INFO Included extra file "/etc/supervisor/conf.d/selenium.conf" during parsing
2019-04-24 19:09:26,881 INFO supervisord started with pid 8
2019-04-24 19:09:27,865 INFO spawned: 'xvfb' with pid 11
2019-04-24 19:09:27,867 INFO spawned: 'selenium-standalone' with pid 12
19:09:28.038 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
2019-04-24 19:09:28,039 INFO success: xvfb entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
2019-04-24 19:09:28,039 INFO success: selenium-standalone entered RUNNING state, process has stayed up for > than 0 seconds (startsecs)
19:09:28.093 INFO [GridLauncherV3.lambda$buildLaunchers$3] - Launching a standalone Selenium Server on port 4444
2019-04-24 19:09:28.126:INFO::main: Logging initialized #247ms to org.seleniumhq.jetty9.util.log.StdErrLog
19:09:28.289 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
19:09:28.349 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
19:09:43.631 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "chrome",
"version": ""
}
19:09:43.633 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.grid.session.remote.ServicedSession$Factory (provider: org.openqa.selenium.chrome.ChromeDriverService)
Starting ChromeDriver 74.0.3729.6 (255758eccf3d244491b8a1317aa76e1ce10d57e9-refs/branch-heads/3729#{#29}) on port 22103
Only local connections are allowed.
Please protect ports used by ChromeDriver and related test frameworks to prevent access by malicious code.
[1556132983.659][SEVERE]: bind() failed: Cannot assign requested address (99)
19:09:44.266 INFO [ProtocolHandshake.createSession] - Detected dialect: OSS
19:09:44.490 INFO [RemoteSession$Factory.lambda$performHandshake$0] - Started new session cedc7067c0133f6492ff65dda5c7dd88 (org.openqa.selenium.chrome.ChromeDriverService)
In particular, I'm unsure of how to fix this error:
[1556132983.659][SEVERE]: bind() failed: Cannot assign requested address (99)
I'm running this on my macbook pro using Mojave with the latest version of docker, python, and selenium. I also tried using other ports aside from 4444, same result. Thanks!
We have seen that entry in the logs for a long time, however, there is no evidence it affects your tests. The message comes directly from ChromeDriver/Chrome. It is safe to ignore it.

selenium server standalone: unable to create a new session with vagrant in headless mode

I am trying to run the selenium server standalone in a vagrant box, with the following command:
java -jar selenium-server-standalone-3.13.0.jar
When I click the 'create session' button at http://lab.local:4444/wd/hub/static/resource/hub.html from my host web browser. I get a unable to create a new session error message.
I ask to create a firefox browser session for which I get the driver located in /usr/local/bin/geckodriver.
Firefox has been installed on the vagrant box with sudo apt install firefox-esr.
Error log detail:
14:52:04.485 INFO [GridLauncherV3.launch] - Selenium build info: version: '3.13.0', revision: '2f0d292'
14:52:04.486 INFO [GridLauncherV3$1.launch] - Launching a standalone Selenium Server on port 4444
2018-08-09 14:52:04.564:INFO::main: Logging initialized #312ms to org.seleniumhq.jetty9.util.log.StdErrLog
14:52:04.757 INFO [SeleniumServer.boot] - Selenium Server is up and running on port 4444
14:52:15.563 INFO [ActiveSessionFactory.apply] - Capabilities are: {
"browserName": "firefox"
}
14:52:15.568 INFO [ActiveSessionFactory.lambda$apply$11] - Matched factory org.openqa.selenium.remote.server.ServicedSession$Factory (provider: org.openqa.selenium.firefox.GeckoDriverService)
1533819135611 geckodriver INFO geckodriver 0.21.0
1533819135614 geckodriver INFO Listening on 127.0.0.1:25541
1533819135880 mozrunner::runner INFO Running command: "/usr/bin/firefox" "-marionette" "-foreground" "-no-remote" "-profile" "/tmp/rust_mozprofile.yuusnpGo8Gw6"
1533819136508 Marionette INFO Listening on port 2828
When I run the same executable directly from my host, I get no error and the firefox session is created with success.
I try to run a X server, Xvfb as follow but this does not change anything:
Xvfb :1 -screen 0 1600x1200x16 &
export DISPLAY=:1
java -jar selenium-server-standalone-3.13.0.jar
Problem solved after switching to selenium-server-standalone-3.3.1.jar with geckodriver 0.14.0. Sessions are created with success with this configuration.
source.

Selenium Hub + Node: Cleaning up stale test sessions on the unregistered node

I have two machines:
1. Linux Centos 6.4
2. Mac OS X 10.8
Linux starts the hub:
[root#jenkins tools]# java -jar selenium-server-standalone-2.46.0.jar -role hub -port 4444
11:35:00.898 INFO - Launching Selenium Grid hub
2015-06-15 11:35:01.744:INFO:osjs.Server:jetty-7.x.y-SNAPSHOT
2015-06-15 11:35:01.969:INFO:osjsh.ContextHandler:started o.s.j.s.ServletContextHandler{/,null}
2015-06-15 11:35:02.028:INFO:osjs.AbstractConnector:Started SocketConnector#0.0.0.0:4444
11:35:02.029 INFO - Nodes should register to http://192.168.1.110:4444/grid/register/
11:35:02.031 INFO - Selenium Grid hub is up and running
Then I start the node (Mac):
tomas#tororrosso ~/Q/A/tools> java -jar selenium-server-standalone-2.46.0.jar -role node -hub http://192.168.1.110:4444/grid/register/ -host "http://192.168.1.254" -port 4445 --debug
11:36:00.190 INFO - Launching a Selenium Grid node
11:36:00.635 INFO - Java: Apple Inc. 20.51-b01-457
11:36:00.635 INFO - OS: Mac OS X 10.8.5 x86_64
11:36:00.639 INFO - v2.46.0, with Core v2.46.0. Built from revision 87c69e2
11:36:00.675 INFO - Driver provider org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{platform=WINDOWS, ensureCleanSession=true, browserName=internet explorer, version=}] does not match the current platform MAC
11:36:00.676 INFO - Driver class not found: com.opera.core.systems.OperaDriver
11:36:00.676 INFO - Driver provider com.opera.core.systems.OperaDriver is not registered
11:36:00.678 INFO - Driver class is built for higher Java version: org.openqa.selenium.htmlunit.HtmlUnitDriver
11:36:00.678 INFO - Driver provider org.openqa.selenium.htmlunit.HtmlUnitDriver is not registered
11:36:00.693 INFO - Version Jetty/5.1.x
11:36:00.694 INFO - Started HttpContext[/selenium-server/driver,/selenium-server/driver]
11:36:00.694 INFO - Started HttpContext[/selenium-server,/selenium-server]
11:36:00.694 INFO - Started HttpContext[/,/]
11:36:00.700 INFO - Started org.openqa.jetty.jetty.servlet.ServletHandler#65493102
11:36:00.700 INFO - Started HttpContext[/wd,/wd]
11:36:00.702 INFO - Started SocketListener on 0.0.0.0:4445
11:36:00.702 INFO - Started org.openqa.jetty.jetty.Server#2092dcdb
11:36:00.703 INFO - Selenium Grid node is up and ready to register to the hub
11:36:00.726 INFO - Starting auto registration thread. Will try to register every 5000 ms.
11:36:00.727 INFO - Registering the node to the hub: http://192.168.1.110:4444/grid/register
11:36:00.735 INFO - The node is registered to the hub and ready to use
Everything seems so perfect and wonderful until....
In the hub:
11:36:50.904 WARN - Cleaning up stale test sessions on the unregistered node http://http://192.168.1.254:4445
And the node:
11:36:05.774 INFO - Registering the node to the hub: http://192.168.1.110:4444/grid/register
11:36:05.785 INFO - The node is registered to the hub and ready to use
And they are like this to the infinity and beyond.
More Information
Both machines can see each other:
tomas#tororrosso ~> ping 192.168.1.110
PING 192.168.1.110 (192.168.1.110): 56 data bytes
64 bytes from 192.168.1.110: icmp_seq=0 ttl=64 time=0.585 ms
64 bytes from 192.168.1.110: icmp_seq=1 ttl=64 time=0.586 ms
64 bytes from 192.168.1.110: icmp_seq=2 ttl=64 time=0.606 ms
^C
--- 192.168.1.110 ping statistics ---
3 packets transmitted, 3 packets received, 0.0% packet loss
round-trip min/avg/max/stddev = 0.585/0.592/0.606/0.010 ms
[root#jenkins ]# ping 192.168.1.254
PING 192.168.1.254 (192.168.1.254) 56(84) bytes of data.
64 bytes from 192.168.1.254: icmp_seq=1 ttl=64 time=0.521 ms
64 bytes from 192.168.1.254: icmp_seq=2 ttl=64 time=0.541 ms
^C
--- 192.168.1.254 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1933ms
rtt min/avg/max/mdev = 0.521/0.531/0.541/0.010 ms
I tried this too:
java -jar selenium-server-standalone-2.46.0.jar -role node -hubHost 192.168.1.110 -hubPort 4444 -host "http://192.168.1.254" -port 4446 --debug
But every 5 seconds it keeps re-registering.
I just executed the node with this config and it worked:
{
"capabilities":
[
{
"browserName": "firefox",
"version": "38.0.5",
"platform": "MAC",
"maxInstances": 1
},
{
"browserName": "chrome",
"version": "43",
"platform": "MAC",
"maxInstances": 1
}
],
"configuration":
{
"nodeTimeout":120,
"host":"192.168.1.254",
"port":4446,
"hubPort":4444,
"hubHost":"192.168.1.110",
"nodePolling":2000,
"registerCycle":10000,
"register":true,
"cleanUpCycle":2000,
"timeout":30000,
"maxSession":1
}
}
Saved it as mac.json
Then executed the node as:
tomas#tororrosso ~> java -jar selenium-server-standalone-2.46.0.jar -role node -nodeConfig mac.json
And everything worked correctly.

Setting up Selenium Grid - A Second Node on MAC -Registration Failure

Tried to setup a Selenium node on Mac using:
java -jar selenium-server-standalone-2.44.0.jar -role node \
-hub http://<<Hub Ip>> :4444/grid/regsiter -port 5557 \
-browser browserName=firefox,platform=MAC \
-remoteHost http://<<Remote Ip>>:5557
Error:
11:34:11.014 INFO - Adding browserName=firefox,platform=MAC
11:34:11.016 INFO - Adding browserName=chrome,platform=MAC
11:35:27.004 WARN - error getting the parameters from the hub. The
node may end up with wrong timeouts.Connect to Hub IP:80 [/Hub
IP] failed: Operation timed out 11:35:27.028 INFO - Java: Oracle
Corporation 23.25-b01 11:35:27.028 INFO - OS: Mac OS X 10.10.2 x86_64
11:35:27.038 INFO - v2.44.0, with Core v2.44.0. Built from revision
76d78cf 11:35:27.198 INFO - Default driver
org.openqa.selenium.ie.InternetExplorerDriver registration is skipped:
registration capabilities Capabilities [{platform=WINDOWS,
ensureCleanSession=true, browserName=internet explorer, version=}]
does not match with current platform: MAC 11:35:27.254 INFO -
RemoteWebDriver instances should connect to:
http://127.0.0.1:5556/wd/hub 11:35:27.256 INFO - Version Jetty/5.1.x
11:35:27.259 INFO - Started
HttpContext[/selenium-server/driver,/selenium-server/driver]
11:35:27.260 INFO - Started
HttpContext[/selenium-server,/selenium-server] 11:35:27.261 INFO -
Started HttpContext[/,/] 11:35:27.294 INFO - Started
org.openqa.jetty.jetty.servlet.ServletHandler#5f6b70e1 11:35:27.295
INFO - Started HttpContext[/wd,/wd] 11:35:27.299 INFO - Started
SocketListener on 0.0.0.0:5556 11:35:27.299 INFO - Started
org.openqa.jetty.jetty.Server#2c11c55b 11:35:27.346 INFO - using the
json request :
{"class":"org.openqa.grid.common.RegistrationRequest","configuration":{"register":true,"port":5556,"host":"<>","proxy":"org.openqa.grid.selenium.proxy.DefaultRemoteProxy","browser":"browserName\u003dfirefox,platform\u003dMAC","maxSession":5,"role":"node","hubHost":"Hub
IP","registerCycle":5000,"hub":"http://<Remote
IP:5556","remoteHost":"http://Remote Ip:5556"},"capabilities":[{"seleniumProtocol":"WebDriver","platform":"MAC","browserName":"firefox"},{"seleniumProtocol":"WebDriver","platform":"MAC","browserName":"chrome"}]}
11:35:27.347 INFO - Starting auto register thread. Will try to
register every 5000 ms. 11:35:27.347 INFO - Registering the node to
hub :http://**Remote IP:-1/grid/register 11:36:43.151 INFO -
couldn't register this node : Error sending the registration request
Your command appears to have a typo.
-hub http://<<Hub Ip>> :4444/grid/regsiter
^ ^^
here and here
Change this to:
-hub http://<<hubip>>:4444/grid/register
^ ^^
no space fix transposition
Additionally, I've always used the directive -hubUrl, not -hub. They may be synonyms, but if this solution I provided above still does not work, try also replacing -hub with -hubUrl.