Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

[馃殌 Feature]: Degrade more gracefully if relay server is not reachable #10908

Closed
mythsunwind opened this issue Jul 27, 2022 · 3 comments
Closed

Comments

@mythsunwind
Copy link

Feature and motivation

Currently the node stops with a NullPointerException if the relay server is not reachable.

Example:

relay.toml

[server]
port = 5555

[node]
detect-drivers = false

[relay]
url = "http://localhost:4723"
status-endpoint = "/status"
configs = [
  "1", "{\"browserName\": \"chrome\", \"platformName\": \"android\", \"version\": \"11\"}"
]

Running java -jar selenium-server-4.3.0.jar node --config relay.toml results in the following output if localhost:4723 cannot be reached:

11:12:01.767 INFO [LoggingOptions.configureLogEncoding] - Using the system default encoding
11:12:01.771 INFO [OpenTelemetryTracer.createTracer] - Using OpenTelemetry for tracing
11:12:01.881 INFO [UnboundZmqEventBus.<init>] - Connecting to tcp://0.0.0.0:4442 and tcp://0.0.0.0:4443
11:12:01.923 INFO [UnboundZmqEventBus.<init>] - Sockets created
11:12:02.929 INFO [UnboundZmqEventBus.<init>] - Event bus ready
11:12:03.054 INFO [NodeServer.createHandlers] - Reporting self as: http://192.168.121.96:5555
11:12:03.075 INFO [NodeOptions.getSessionFactories] - Detected 8 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:151)
	at org.openqa.selenium.grid.node.httpd.NodeServer.createHandlers(NodeServer.java:127)
	at org.openqa.selenium.grid.node.httpd.NodeServer.asServer(NodeServer.java:183)
	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: org.openqa.selenium.grid.config.ConfigException: Unable to reach the service at http://localhost:4723
	at org.openqa.selenium.grid.node.relay.RelayOptions.isServiceUp(RelayOptions.java:119)
	at org.openqa.selenium.grid.node.relay.RelayOptions.getSessionFactories(RelayOptions.java:131)
	at org.openqa.selenium.grid.node.local.LocalNodeFactory.create(LocalNodeFactory.java:89)
	... 22 more
Exception in thread "Thread-0" java.lang.NullPointerException
	at org.openqa.selenium.grid.node.httpd.NodeServer.lambda$new$0(NodeServer.java:79)
	at java.base/java.lang.Thread.run(Thread.java:829)

The output contains a clear error message why it is not working (Unable to reach the service at http://localhost:4723) but the java program completely exits leaving no possibility that the relay server is slow in starting up or is only temporary unreachable.

Usage example

A retry mechanism would make it possible that the node does not need to be restarted every time the relay server is too slow in starting up (happens with appium) or is only temporary unreachable.

@github-actions
Copy link

@mythsunwind, thank you for creating this issue. We will troubleshoot it as soon as we can.


Info for maintainers

Triage this issue by using labels.

If information is missing, add a helpful comment and then I-issue-template label.

If the issue is a question, add the I-question label.

If the issue is valid but there is no time to troubleshoot it, consider adding the help wanted label.

If the issue requires changes or fixes from an external project (e.g., ChromeDriver, GeckoDriver, MSEdgeDriver, W3C), add the applicable G-* label, and it will provide the correct link and auto-close the issue.

After troubleshooting the issue, please add the R-awaiting answer label.

Thank you!

@diemol
Copy link
Member

diemol commented Aug 3, 2022

Thanks for the report, @mythsunwind. It does make sense. I've pushed a fix and it will be included in 4.4, which should be released in 1-2 days.

@github-actions
Copy link

github-actions bot commented Sep 3, 2022

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.

@github-actions github-actions bot locked and limited conversation to collaborators Sep 3, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants