SeleniumHQ / selenium

A browser automation framework and ecosystem.
https://selenium.dev
Apache License 2.0
30.21k stars 8.11k forks source link

Selenium v3 cannot bind to a port on the Public IP using "host" in an Openstack Environment #7209

Closed bonjonbovi87 closed 4 years ago

bonjonbovi87 commented 5 years ago

🐛 Problem

A Win 10 Openstack VM cannot bind to any given port using the "host" parameter using selenium v3.141.59. This does work on the same VM for selenium v2.53.1 -- something broke this in selenium v3.

c:\selenium>java -jar selenium-v3.jar -role node -hub "http://135.121.105.203:4445" -nodeConfig nodeconfig-v3.json

14:01:15.982 INFO [GridLauncherV3.parse] - Selenium server version: 3.141.59, revision: e82be7d358
14:01:16.272 INFO [GridLauncherV3.lambda$buildLaunchers$7] - Launching a Selenium Grid node on port 5555
2019-05-15 14:01:16.824:INFO::main: Logging initialized @1496ms to org.seleniumhq.jetty9.util.log.StdErrLog
14:01:17.391 INFO [WebDriverServlet.<init>] - Initialising WebDriverServlet
14:01:17.585 ERROR [BaseServer.start] - Port 5555 is busy, please choose a free port and specify it using -port option
Exception in thread "main" java.lang.RuntimeException: java.net.BindException: Cannot assign requested address: bind
        at org.openqa.selenium.grid.server.BaseServer.start(BaseServer.java:221)
        at org.openqa.selenium.remote.server.SeleniumServer.boot(SeleniumServer.java:131)
        at org.openqa.grid.internal.utils.SelfRegisteringRemote.startRemoteServer(SelfRegisteringRemote.java:119)
        at org.openqa.grid.selenium.GridLauncherV3.lambda$buildLaunchers$7(GridLauncherV3.java:284)
        at org.openqa.grid.selenium.GridLauncherV3.lambda$launch$0(GridLauncherV3.java:86)
        at java.util.Optional.map(Unknown Source)
        at org.openqa.grid.selenium.GridLauncherV3.launch(GridLauncherV3.java:86)
        at org.openqa.grid.selenium.GridLauncherV3.main(GridLauncherV3.java:70)
Caused by: java.net.BindException: Cannot assign requested address: bind
        at sun.nio.ch.Net.bind0(Native Method)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.Net.bind(Unknown Source)
        at sun.nio.ch.ServerSocketChannelImpl.bind(Unknown Source)
        at sun.nio.ch.ServerSocketAdaptor.bind(Unknown Source)
        at org.seleniumhq.jetty9.server.ServerConnector.openAcceptChannel(ServerConnector.java:339)
        at org.seleniumhq.jetty9.server.ServerConnector.open(ServerConnector.java:307)
        at org.seleniumhq.jetty9.server.AbstractNetworkConnector.doStart(AbstractNetworkConnector.java:80)
        at org.seleniumhq.jetty9.server.ServerConnector.doStart(ServerConnector.java:235)
        at org.seleniumhq.jetty9.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.seleniumhq.jetty9.server.Server.doStart(Server.java:395)
        at org.seleniumhq.jetty9.util.component.AbstractLifeCycle.start(AbstractLifeCycle.java:68)
        at org.openqa.selenium.grid.server.BaseServer.start(BaseServer.java:202)
        ... 7 more

The nodeConfig contains this configuration

    "maxSession": 3,
    "register": true,
    "registerCycle": 5000,
    "port": 5555,
    "host": "135.228.149.0",

    "cleanUpCycle": 10000,
    "browserTimeout": 300,
    "timeout": 300

Workaround Steps

  1. Connect node to the hub using selenium 2.53.1 with host=, and port=5555
  2. Kill selenium on node once registered to grid
  3. While hub still has reference to node, restart selenium using v3.141.59 on port 5555 (not as a node, and do not specify host)
  4. Hub will be able to reconnect to PUBLIC_IP:5555 and will keep it registered in /grid/console, showing the selenium version to be 3.141.59

Environment

OS: Windows 10 in Openstack Browser: N/A Browser version: N/A Browser Driver version: N/A Language Bindings version: Java 3.141.0 Selenium Grid version (if applicable): 3.141.59

flynet commented 5 years ago

What do you mean by "not as a node" ? It adds another node with different version when role node.. without role it starts hub ..

bonjonbovi87 commented 5 years ago

So this is the workaround to the problem, but I'll better explain it. I have selenium running as a hub on one machine (A), and another machine I want to use as a node (B).

I start my node using selenium 2.53.1 on (B), specify the host IP, port 5555, and role node.

Once registered with the hub (A), I kill the selenium process on the worker (B) and restart it using v3.141.59 but as a hub (not as role=node) on port 5555.

My original hub (A) still contains a reference to the host IP on port 5555, so when my worker (B) starts up, it's considered registered and can be accessed like any normal node on the hub.


I don't have a problem with this functionality, it's just my workaround. The issue is v3.141.59 not properly binding to the open port using the host parameter.

diemol commented 4 years ago

Apologies for the late reply, is this issue still happening? Is there something else running in port 5555? What if you try a different port?

diemol commented 4 years ago

Closing as the issue went stale.

bonjonbovi87 commented 4 years ago

Nothing else is running on port 5555 and using selenium 2.53.1 I can bind to port 5555. I've tried several other ports

diemol commented 4 years ago

This looks like an environment issue, how can we reproduce it?

bonjonbovi87 commented 4 years ago

Run Windows 10 in Openstack where the VM has a private IP and a public IP. Bind to the public IP using the host parameter

It works with selenium v2.53.1 but doesn't in v3

diemol commented 4 years ago

Fair point, sadly we don't have the means to afford that type of environment. Could you please try with the new Selenium Grid 4 alphas and if not working, report in a new issue with all details?

diemol commented 4 years ago

Downloads link https://www.selenium.dev/downloads/

bonjonbovi87 commented 4 years ago

Sure, I can follow up later today or tomorrow

bonjonbovi87 commented 4 years ago

@diemol It appears to be working for nodes in v4 alpha, however I can't figure out how to specify a hub IP for this node to connect to so I can't say for 100% certain.

c:\selenium>java -jar selenium-server-4.0.0-alpha-5.jar node --host 135.228.131.74
16:31:45.220 INFO [EventBusOptions.createBus] - Creating event bus: org.openqa.selenium.events.zeromq.ZeroMqEventBus
16:31:45.592 INFO [UnboundZmqEventBus.<init>] - Connecting to tcp://*:4442 and tcp://*:4443
16:31:45.714 INFO [UnboundZmqEventBus.<init>] - Sockets created
16:31:45.724 INFO [UnboundZmqEventBus.lambda$new$2] - Bus started
16:31:45.937 INFO [NodeServer.lambda$configure$1] - Reporting self as: http://135.228.131.74:5555
16:31:46.079 INFO [NodeOptions.lambda$addSystemDrivers$1] - Adding Capabilities {browserName: firefox} 3 times
16:31:46.085 INFO [NodeOptions.lambda$addSystemDrivers$1] - Adding Capabilities {browserName: internet explorer} 1 times
16:31:46.087 INFO [NodeOptions.lambda$addSystemDrivers$1] - Adding Capabilities {browserName: MicrosoftEdge} 3 times
16:31:46.092 INFO [NodeOptions.lambda$addSystemDrivers$1] - Adding Capabilities {browserName: MicrosoftEdge} 3 times
16:31:47.002 INFO [NodeServer.lambda$configure$1] - Started Selenium node 4.0.0-alpha-5 (revision b3a0d621cc)

When specifying the --host parameter in hub mode, it does not appear to say it has bound to the specified host (public ip) but it could have

c:\selenium>java -jar selenium-server-4.0.0-alpha-5.jar hub --host 135.228.131.74 --port 4444
16:36:25.281 INFO [EventBusOptions.createBus] - Creating event bus: org.openqa.selenium.events.zeromq.ZeroMqEventBus
16:36:25.945 INFO [BoundZmqEventBus.<init>] - XPUB binding to [binding to tcp://*:4442, advertising as tcp://192.168.96.23:4442], XSUB binding to [binding to tcp://*:4443, advertising as tcp://192.168.96.23:4443]
16:36:26.184 INFO [UnboundZmqEventBus.<init>] - Connecting to tcp://192.168.96.23:4442 and tcp://192.168.96.23:4443
16:36:26.211 INFO [UnboundZmqEventBus.<init>] - Sockets created
16:36:26.301 INFO [UnboundZmqEventBus.lambda$new$2] - Bus started
16:36:26.500 INFO [BoundZmqEventBus.<init>] - Event bus ready
16:36:27.737 INFO [Hub.lambda$configure$0] - Started Selenium hub 4.0.0-alpha-5 (revision b3a0d621cc)

I also have no idea what the new endpoints are as / and /grid/console are not valid for the hub anymore

{
  "value": {
    "error": "unknown command",
    "message": "Unable to find handler for (GET) /",
    "stacktrace": ""
  }
}