SeleniumHQ / selenium

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

java.util.concurrent.TimeoutException thrown at random netty read timeouts with RemoteWebDriver #9528

Closed rcesarlumis closed 1 year ago

rcesarlumis commented 3 years ago

🐛 Bug Report

Netty at random times gets a read timeout at. This happens at different selenium commands ( for example: WebDriver.switchTo().defaultContent, WebElement.click, WebDriver.switchTo().window, WebElement.sendKeys, WebDriver.get, Alert.accept ) and at random in a quite small percentage chance (<1% test cases).

To Reproduce

I don't have specific steps to reproduce. When our CI runs our test suite of thousands of tests run, about 10 fails at random due to this timeout. I could not reproduce by doing a simple long loop with a few commands on my development workstation.

Timeout details

This timeout always occurs at:

Caused by: java.util.concurrent.TimeoutException
    at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1886)
    at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2021)
    at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:206)
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:65)

I could confirm that it took 3 minutes there, confirming that it is due to the default 3 minutes read timeout the selenium configures the netty with. But the commands that are timing outs would normally run very fast, much less than one second.

Trying the code below in a method called probably thousands times by my test suite, it failed entering the catch. But after it called again driver.switchTo().defaultContent() at the end of the code below it worked. So it seems that although the read timeout happens in netty, it still works normally afterwards.

try
{
driver.switchTo().defaultContent();
}
catch (TimeoutException e)
{
// this should never happen, but started happening at random after updating to selenium 4
// output information to help troubleshoot
System.err.println("TimeoutException thrown while trying to go to defaultContent (stack below). Trying again...");
e.printStackTrace();

try
{
Thread.sleep(5000);
}
catch (InterruptedException e1)
{
}

driver.switchTo().defaultContent();
}

In this case, the stack trace got by the e.printStackTrace() above was:

org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException
Build info: version: '4.0.0-beta-3', revision: '5d108f9a67'
System info: host: '51e5404d333b', ip: '172.18.0.7', os.name: 'Linux', os.arch: 'amd64', os.version: '3.10.0-1127.19.1.el7.x86_64', java.version: '11.0.1'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [a5e3bf25-ba72-4023-b219-76406cf58660, switchToFrame {id=null}]
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 88.0, javascriptEnabled: true, moz:accessibilityChecks: false, moz:buildID: 20210415204500, moz:debuggerAddress: localhost:46562, moz:geckodriverVersion: 0.29.0, moz:headless: false, moz:processID: 9286, moz:profile: /tmp/rust_mozprofileQJRwQP, moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platform: LINUX, platformName: LINUX, platformVersion: 3.10.0-1127.19.1.el7.x86_64, rotatable: false, se:cdp: ws://172.18.0.3:4444/sessio..., se:cdpVersion: 85, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: a5e3bf25-ba72-4023-b219-76406cf58660
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:71)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:51)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:103)
    at org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:55)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:181)
    at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:39)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:619)
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.defaultContent(RemoteWebDriver.java:1097)
    (...)
Caused by: java.util.concurrent.TimeoutException
    at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1886)
    at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2021)
    at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:206)
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:65)
    ... 38 more

Environment

OS: Docker containers inside a CentOS Browser: RemoteWebDriver using Firefox in selenium/standalone-firefox:4.0.0-beta-3-20210426 docker image. Also tried the selenium/standalone-firefox:4.0.0-beta-4-prerelease-20210527 docker image, but the same thing happened. Browser Driver version: RemoteWebDriver from selenium-java 4.0.0-beta-3 Language Bindings version: Java 4.0.0-beta-3 The RemoteWebDriver runs in a container that is running in the same docker host as the browser container. So all network between them is only logical in the same machine. Previously we were using Selenium 2.52, in the same docker host, and never happened anything similar to such timeout.

Do you have any tips about what I can try to fix it or investigate more about this?

diemol commented 2 years ago

4.2.0, we'd be thankful if you can give us more feedback based on this version.

JulienBreton commented 2 years ago

@diemol I can reproduce the java.util.concurrent.TimeoutException with the 4.2.0

I add a file with more logs. selenium_4.2.0_logs_3005.txt

[35mselenium-hub_1  |[0m 07:36:24.472 DEBUG [TimeoutTimerTask.expire] - Request timeout to 172.18.0.5/172.18.0.5:5555 after 180000 ms for NettyResponseFuture{currentRetry=0,
[35mselenium-hub_1  |[0m    isDone=0,
[35mselenium-hub_1  |[0m    isCancelled=0,
[35mselenium-hub_1  |[0m    asyncHandler=org.asynchttpclient.AsyncCompletionHandlerBase@4d1dd9c1,
[35mselenium-hub_1  |[0m    nettyRequest=org.asynchttpclient.netty.request.NettyRequest@11670799,
[35mselenium-hub_1  |[0m    future=java.util.concurrent.CompletableFuture@27701a05[Not completed],
[35mselenium-hub_1  |[0m    uri=http://172.18.0.5:5555/session/2b036b3c893b6f3780071155cb9e67e7/timeouts,
[35mselenium-hub_1  |[0m    keepAlive=true,
[35mselenium-hub_1  |[0m    redirectCount=0,
[35mselenium-hub_1  |[0m    timeoutsHolder=org.asynchttpclient.netty.timeout.TimeoutsHolder@6aa36f29,
[35mselenium-hub_1  |[0m    inAuth=0,
[35mselenium-hub_1  |[0m    touch=1653896004378} after 180094 ms
[36mchrome_1        |[0m 07:36:24.473 DEBUG [RequestConverter.channelInactive] - Closing input pipe, channel became inactive.
[35mselenium-hub_1  |[0m 07:36:24.472 DEBUG [ChannelManager.closeChannel] - Closing Channel [id: 0xd7b8a183, L:/172.18.0.2:56434 - R:/172.18.0.5:5555] 
[35mselenium-hub_1  |[0m 07:36:24.473 DEBUG [NettyRequestSender.abort] - Aborting Future NettyResponseFuture{currentRetry=0,
[35mselenium-hub_1  |[0m    isDone=0,
[35mselenium-hub_1  |[0m    isCancelled=0,
[35mselenium-hub_1  |[0m    asyncHandler=org.asynchttpclient.AsyncCompletionHandlerBase@4d1dd9c1,
[35mselenium-hub_1  |[0m    nettyRequest=org.asynchttpclient.netty.request.NettyRequest@11670799,
[35mselenium-hub_1  |[0m    future=java.util.concurrent.CompletableFuture@27701a05[Not completed],
[35mselenium-hub_1  |[0m    uri=http://172.18.0.5:5555/session/2b036b3c893b6f3780071155cb9e67e7/timeouts,
[35mselenium-hub_1  |[0m    keepAlive=true,
[35mselenium-hub_1  |[0m    redirectCount=0,
[35mselenium-hub_1  |[0m    timeoutsHolder=org.asynchttpclient.netty.timeout.TimeoutsHolder@6aa36f29,
[35mselenium-hub_1  |[0m    inAuth=0,
[35mselenium-hub_1  |[0m    touch=1653896004378}
[35mselenium-hub_1  |[0m 
[35mselenium-hub_1  |[0m 07:36:24.473 DEBUG [NettyRequestSender.abort] - Request timeout to 172.18.0.5/172.18.0.5:5555 after 180000 ms
[35mselenium-hub_1  |[0m java.util.concurrent.TimeoutException: Request timeout to 172.18.0.5/172.18.0.5:5555 after 180000 ms
[35mselenium-hub_1  |[0m    at org.asynchttpclient.netty.timeout.TimeoutTimerTask.expire(TimeoutTimerTask.java:43)
[35mselenium-hub_1  |[0m    at org.asynchttpclient.netty.timeout.RequestTimeoutTimerTask.run(RequestTimeoutTimerTask.java:50)
[35mselenium-hub_1  |[0m    at io.netty.util.HashedWheelTimer$HashedWheelTimeout.run(HashedWheelTimer.java:715)
[35mselenium-hub_1  |[0m    at io.netty.util.concurrent.ImmediateExecutor.execute(ImmediateExecutor.java:34)
[35mselenium-hub_1  |[0m    at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:703)
[35mselenium-hub_1  |[0m    at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:790)
[35mselenium-hub_1  |[0m    at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:503)
[35mselenium-hub_1  |[0m    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
[35mselenium-hub_1  |[0m    at java.base/java.lang.Thread.run(Thread.java:829)
[35mselenium-hub_1  |[0m 07:36:24.473 DEBUG [AsyncHttpClientHandler.channelInactive] - Channel Closed: [id: 0xd7b8a183, L:/172.18.0.2:56434 ! R:/172.18.0.5:5555] with attribute DISCARD
[35mselenium-hub_1  |[0m 07:36:24.473 DEBUG [AsyncCompletionHandler.onThrowable] - Request timeout to 172.18.0.5/172.18.0.5:5555 after 180000 ms
[35mselenium-hub_1  |[0m java.util.concurrent.TimeoutException: Request timeout to 172.18.0.5/172.18.0.5:5555 after 180000 ms
[35mselenium-hub_1  |[0m    at org.asynchttpclient.netty.timeout.TimeoutTimerTask.expire(TimeoutTimerTask.java:43)
[35mselenium-hub_1  |[0m    at org.asynchttpclient.netty.timeout.RequestTimeoutTimerTask.run(RequestTimeoutTimerTask.java:50)
[35mselenium-hub_1  |[0m    at io.netty.util.HashedWheelTimer$HashedWheelTimeout.run(HashedWheelTimer.java:715)
[35mselenium-hub_1  |[0m    at io.netty.util.concurrent.ImmediateExecutor.execute(ImmediateExecutor.java:34)
[35mselenium-hub_1  |[0m    at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:703)
[35mselenium-hub_1  |[0m    at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:790)
[35mselenium-hub_1  |[0m    at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:503)
[35mselenium-hub_1  |[0m    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
[35mselenium-hub_1  |[0m    at java.base/java.lang.Thread.run(Thread.java:829)
AndreasPetersen commented 2 years ago

I'm also getting a timeout error when I have a session in queue for 3 minutes, despite having configured Selenium Grid to timeout queued sessions after 30 minutes.

Even setting a client timeout, it still times out after 3 minutes.

webDriver = RemoteWebDriver.builder().config(
                                ClientConfig.defaultConfig()
                                        .readTimeout(Duration.ofMinutes(30)))
                        .address(new URL(config.getValue("webdriver.remote.url", String.class)))
                        .setCapability(ChromeOptions.CAPABILITY, options)
                        .build();
Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '4.2.1', revision: 'ac4d0fdd4a'
System info: host: '', ip: '', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.15'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-features=ChromeWh...], extensions: [], prefs: {download.default_directory: Temp}}, goog:loggingPrefs: org.openqa.selenium.logging...}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-features=ChromeWh...], extensions: [], prefs: {download.default_directory: Temp}}, loggingPrefs: org.openqa.selenium.logging...}}]
Capabilities {}
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '4.2.1', revision: 'ac4d0fdd4a'
System info: host: '', ip: '', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.15'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-features=ChromeWh...], extensions: [], prefs: {download.default_directory: Temp}}, goog:loggingPrefs: org.openqa.selenium.logging...}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-features=ChromeWh...], extensions: [], prefs: {download.default_directory: Temp}}, loggingPrefs: org.openqa.selenium.logging...}}]
Capabilities {}
    at app//org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:569)
    at app//org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:246)
    at app//org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:162)
    at app//org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
    at app//dk.ape.selenium.core.WebCore.<init>(WebCore.java:76)
    at app//dk.ape.selenium.extensions.testrunner.TestRunner.<init>(TestRunner.java:31)
    at app//dk.ape.selenium.extensions.testrunner.TestRunnerExtension.beforeEach(TestRunnerExtension.java:27)
    at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachCallbacks$2(TestMethodTestDescriptor.java:163)
    at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$6(TestMethodTestDescriptor.java:199)
    at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:199)
    at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachCallbacks(TestMethodTestDescriptor.java:162)
    at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:129)
    at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
    at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
    at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at app//org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:185)
    at app//org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService.invokeAll(ForkJoinPoolHierarchicalTestExecutorService.java:129)
    at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at app//org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:185)
    at app//org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService.invokeAll(ForkJoinPoolHierarchicalTestExecutorService.java:129)
    at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
    at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
    at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
    at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
    at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
    at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
    at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
    at app//org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:185)
    at java.base@11.0.15/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:189)
    at java.base@11.0.15/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
    at java.base@11.0.15/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
    at java.base@11.0.15/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
    at java.base@11.0.15/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
    at java.base@11.0.15/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: java.lang.RuntimeException: NettyHttpHandler request execution error
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:76)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:98)
    at org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:55)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:120)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:102)
    at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:156)
    at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:551)
    ... 48 more
Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.TimeoutException: Request timeout to selenium-hub-wea-staging.apps.c02u.paastools.dk/10.197.103.78:443 after 180000 ms
    at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
    at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2022)
    at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:206)
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:59)
    ... 61 more
Caused by: java.util.concurrent.TimeoutException: Request timeout to selenium-hub-wea-staging.apps.c02u.paastools.dk/10.197.103.78:443 after 180000 ms
    at org.asynchttpclient.netty.timeout.TimeoutTimerTask.expire(TimeoutTimerTask.java:43)
    at org.asynchttpclient.netty.timeout.RequestTimeoutTimerTask.run(RequestTimeoutTimerTask.java:50)
    at io.netty.util.HashedWheelTimer$HashedWheelTimeout.run(HashedWheelTimer.java:715)
    at io.netty.util.concurrent.ImmediateExecutor.execute(ImmediateExecutor.java:34)
    at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:703)
    at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:790)
    at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:503)
    at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
    at java.base/java.lang.Thread.run(Thread.java:829)
bryanvaldellonsdet commented 2 years ago

still getting the concurrent timeout exception after updating to 4.2.1. Our current workaround is to use windows machines than linux until this is fixed. :) thank you for working on it :)

org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException
Build info: version: '4.2.1', revision: 'ac4d0fdd4a'
System info: host: 'ip-172-28-34-75', ip: '172.28.34.75', os.name: 'Linux', os.arch: 'amd64', os.version: '5.11.0-1022-aws', java.version: '11.0.13'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [b709ae86f606c86babdd11b9e05823a5, clickElement {id=e6dacac5-6c71-49b5-847d-1b47ea837c14}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 102.0.5005.61, chrome: {chromedriverVersion: 102.0.5005.61 (0e59bcc00cc4..., userDataDir: /tmp/.com.google.Chrome.1p47fJ}, goog:chromeOptions: {debuggerAddress: localhost:45719}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: LINUX, proxy: Proxy(), se:cdp: ws://localhost:45719/devtoo..., se:cdpVersion: 102.0.5005.61, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Element: [[ChromeDriver: chrome on LINUX (b709ae86f606c86babdd11b9e05823a5)] -> id: kc-login]
Session ID: b709ae86f606c86babdd11b9e05823a5
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:65)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:98)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:181)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:167)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:142)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:551)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:257)
    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:78)
    at utils.ClickUtils.click(ClickUtils.java:36)
    at utils.ClickUtils.click(ClickUtils.java:44)
    at steps.straitsx.frontend.LoginStep.login(LoginStep.java:35)
    at stepdefinitions.straitsx.frontend.LoginStepDefinition.login(LoginStepDefinition.java:17)
    at ✽.user login using "STRAITSX_BIZ_UI_ID_COMMON" account(file:///home/circleci/project/src/test/resources/features/straitsx/frontend/Home.feature:9)
Caused by: java.util.concurrent.TimeoutException
    at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1886)
    at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2021)
    at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:206)
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:59)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49)
    at org.openqa.selenium.remote.http.AddSeleniumUs2022-06-02 02:52:58.820 [TestNG-PoolService-3] DEBUG utils.SystemUtils#getConfig(line:87) - getting config of = take.screenshot.after.step
amitkpal83 commented 2 years ago

still getting the concurrent timeout exception after updating to 4.2.1. Our current workaround is to use windows machines than linux until this is fixed. :) thank you for working on it :)

org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException
Build info: version: '4.2.1', revision: 'ac4d0fdd4a'
System info: host: 'ip-172-28-34-75', ip: '172.28.34.75', os.name: 'Linux', os.arch: 'amd64', os.version: '5.11.0-1022-aws', java.version: '11.0.13'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [b709ae86f606c86babdd11b9e05823a5, clickElement {id=e6dacac5-6c71-49b5-847d-1b47ea837c14}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 102.0.5005.61, chrome: {chromedriverVersion: 102.0.5005.61 (0e59bcc00cc4..., userDataDir: /tmp/.com.google.Chrome.1p47fJ}, goog:chromeOptions: {debuggerAddress: localhost:45719}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: LINUX, proxy: Proxy(), se:cdp: ws://localhost:45719/devtoo..., se:cdpVersion: 102.0.5005.61, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Element: [[ChromeDriver: chrome on LINUX (b709ae86f606c86babdd11b9e05823a5)] -> id: kc-login]
Session ID: b709ae86f606c86babdd11b9e05823a5
  at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:65)
  at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
  at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
  at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49)
  at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
  at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
  at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:98)
  at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:181)
  at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:167)
  at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:142)
  at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:551)
  at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:257)
  at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:78)
  at utils.ClickUtils.click(ClickUtils.java:36)
  at utils.ClickUtils.click(ClickUtils.java:44)
  at steps.straitsx.frontend.LoginStep.login(LoginStep.java:35)
  at stepdefinitions.straitsx.frontend.LoginStepDefinition.login(LoginStepDefinition.java:17)
  at ✽.user login using "STRAITSX_BIZ_UI_ID_COMMON" account(file:///home/circleci/project/src/test/resources/features/straitsx/frontend/Home.feature:9)
Caused by: java.util.concurrent.TimeoutException
  at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1886)
  at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2021)
  at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:206)
  at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:59)
  at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
  at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
  at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49)
  at org.openqa.selenium.remote.http.AddSeleniumUs2022-06-02 02:52:58.820 [TestNG-PoolService-3] DEBUG utils.SystemUtils#getConfig(line:87) - getting config of = take.screenshot.after.step

Hi,

Is this not happening in Windows?

diemol commented 2 years ago

@diemol I can reproduce the java.util.concurrent.TimeoutException with the 4.2.0

I add a file with more logs. selenium_4.2.0_logs_3005.txt

[35mselenium-hub_1  |[0m 07:36:24.472 DEBUG [TimeoutTimerTask.expire] - Request timeout to 172.18.0.5/172.18.0.5:5555 after 180000 ms for NettyResponseFuture{currentRetry=0,
[35mselenium-hub_1  |[0m  isDone=0,
[35mselenium-hub_1  |[0m  isCancelled=0,
[35mselenium-hub_1  |[0m  asyncHandler=org.asynchttpclient.AsyncCompletionHandlerBase@4d1dd9c1,
[35mselenium-hub_1  |[0m  nettyRequest=org.asynchttpclient.netty.request.NettyRequest@11670799,
[35mselenium-hub_1  |[0m  future=java.util.concurrent.CompletableFuture@27701a05[Not completed],
[35mselenium-hub_1  |[0m  uri=http://172.18.0.5:5555/session/2b036b3c893b6f3780071155cb9e67e7/timeouts,
[35mselenium-hub_1  |[0m  keepAlive=true,
[35mselenium-hub_1  |[0m  redirectCount=0,
[35mselenium-hub_1  |[0m  timeoutsHolder=org.asynchttpclient.netty.timeout.TimeoutsHolder@6aa36f29,
[35mselenium-hub_1  |[0m  inAuth=0,
[35mselenium-hub_1  |[0m  touch=1653896004378} after 180094 ms
[36mchrome_1        |[0m 07:36:24.473 DEBUG [RequestConverter.channelInactive] - Closing input pipe, channel became inactive.
[35mselenium-hub_1  |[0m 07:36:24.472 DEBUG [ChannelManager.closeChannel] - Closing Channel [id: 0xd7b8a183, L:/172.18.0.2:56434 - R:/172.18.0.5:5555] 
[35mselenium-hub_1  |[0m 07:36:24.473 DEBUG [NettyRequestSender.abort] - Aborting Future NettyResponseFuture{currentRetry=0,
[35mselenium-hub_1  |[0m  isDone=0,
[35mselenium-hub_1  |[0m  isCancelled=0,
[35mselenium-hub_1  |[0m  asyncHandler=org.asynchttpclient.AsyncCompletionHandlerBase@4d1dd9c1,
[35mselenium-hub_1  |[0m  nettyRequest=org.asynchttpclient.netty.request.NettyRequest@11670799,
[35mselenium-hub_1  |[0m  future=java.util.concurrent.CompletableFuture@27701a05[Not completed],
[35mselenium-hub_1  |[0m  uri=http://172.18.0.5:5555/session/2b036b3c893b6f3780071155cb9e67e7/timeouts,
[35mselenium-hub_1  |[0m  keepAlive=true,
[35mselenium-hub_1  |[0m  redirectCount=0,
[35mselenium-hub_1  |[0m  timeoutsHolder=org.asynchttpclient.netty.timeout.TimeoutsHolder@6aa36f29,
[35mselenium-hub_1  |[0m  inAuth=0,
[35mselenium-hub_1  |[0m  touch=1653896004378}
[35mselenium-hub_1  |[0m 
[35mselenium-hub_1  |[0m 07:36:24.473 DEBUG [NettyRequestSender.abort] - Request timeout to 172.18.0.5/172.18.0.5:5555 after 180000 ms
[35mselenium-hub_1  |[0m java.util.concurrent.TimeoutException: Request timeout to 172.18.0.5/172.18.0.5:5555 after 180000 ms
[35mselenium-hub_1  |[0m  at org.asynchttpclient.netty.timeout.TimeoutTimerTask.expire(TimeoutTimerTask.java:43)
[35mselenium-hub_1  |[0m  at org.asynchttpclient.netty.timeout.RequestTimeoutTimerTask.run(RequestTimeoutTimerTask.java:50)
[35mselenium-hub_1  |[0m  at io.netty.util.HashedWheelTimer$HashedWheelTimeout.run(HashedWheelTimer.java:715)
[35mselenium-hub_1  |[0m  at io.netty.util.concurrent.ImmediateExecutor.execute(ImmediateExecutor.java:34)
[35mselenium-hub_1  |[0m  at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:703)
[35mselenium-hub_1  |[0m  at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:790)
[35mselenium-hub_1  |[0m  at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:503)
[35mselenium-hub_1  |[0m  at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
[35mselenium-hub_1  |[0m  at java.base/java.lang.Thread.run(Thread.java:829)
[35mselenium-hub_1  |[0m 07:36:24.473 DEBUG [AsyncHttpClientHandler.channelInactive] - Channel Closed: [id: 0xd7b8a183, L:/172.18.0.2:56434 ! R:/172.18.0.5:5555] with attribute DISCARD
[35mselenium-hub_1  |[0m 07:36:24.473 DEBUG [AsyncCompletionHandler.onThrowable] - Request timeout to 172.18.0.5/172.18.0.5:5555 after 180000 ms
[35mselenium-hub_1  |[0m java.util.concurrent.TimeoutException: Request timeout to 172.18.0.5/172.18.0.5:5555 after 180000 ms
[35mselenium-hub_1  |[0m  at org.asynchttpclient.netty.timeout.TimeoutTimerTask.expire(TimeoutTimerTask.java:43)
[35mselenium-hub_1  |[0m  at org.asynchttpclient.netty.timeout.RequestTimeoutTimerTask.run(RequestTimeoutTimerTask.java:50)
[35mselenium-hub_1  |[0m  at io.netty.util.HashedWheelTimer$HashedWheelTimeout.run(HashedWheelTimer.java:715)
[35mselenium-hub_1  |[0m  at io.netty.util.concurrent.ImmediateExecutor.execute(ImmediateExecutor.java:34)
[35mselenium-hub_1  |[0m  at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:703)
[35mselenium-hub_1  |[0m  at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:790)
[35mselenium-hub_1  |[0m  at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:503)
[35mselenium-hub_1  |[0m  at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
[35mselenium-hub_1  |[0m  at java.base/java.lang.Thread.run(Thread.java:829)

@JulienBreton the log is confusing. What is being done in the test? I see several calls to /timeouts, then a session delete, and then more calls to /timeouts. Is there a way you can share a test that demonstrates this behavior?

diemol commented 2 years ago

I'm also getting a timeout error when I have a session in queue for 3 minutes, despite having configured Selenium Grid to timeout queued sessions after 30 minutes.

Even setting a client timeout, it still times out after 3 minutes.

webDriver = RemoteWebDriver.builder().config(
                                ClientConfig.defaultConfig()
                                        .readTimeout(Duration.ofMinutes(30)))
                        .address(new URL(config.getValue("webdriver.remote.url", String.class)))
                        .setCapability(ChromeOptions.CAPABILITY, options)
                        .build();
Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '4.2.1', revision: 'ac4d0fdd4a'
System info: host: '', ip: '', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.15'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-features=ChromeWh...], extensions: [], prefs: {download.default_directory: Temp}}, goog:loggingPrefs: org.openqa.selenium.logging...}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-features=ChromeWh...], extensions: [], prefs: {download.default_directory: Temp}}, loggingPrefs: org.openqa.selenium.logging...}}]
Capabilities {}
org.openqa.selenium.SessionNotCreatedException: Could not start a new session. Possible causes are invalid address of the remote server or browser start-up failure.
Build info: version: '4.2.1', revision: 'ac4d0fdd4a'
System info: host: '', ip: '', os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.15'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [null, newSession {capabilities=[Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-features=ChromeWh...], extensions: [], prefs: {download.default_directory: Temp}}, goog:loggingPrefs: org.openqa.selenium.logging...}], desiredCapabilities=Capabilities {browserName: chrome, goog:chromeOptions: {args: [--disable-features=ChromeWh...], extensions: [], prefs: {download.default_directory: Temp}}, loggingPrefs: org.openqa.selenium.logging...}}]
Capabilities {}
  at app//org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:569)
  at app//org.openqa.selenium.remote.RemoteWebDriver.startSession(RemoteWebDriver.java:246)
  at app//org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:162)
  at app//org.openqa.selenium.remote.RemoteWebDriver.<init>(RemoteWebDriver.java:144)
  at app//dk.ape.selenium.core.WebCore.<init>(WebCore.java:76)
  at app//dk.ape.selenium.extensions.testrunner.TestRunner.<init>(TestRunner.java:31)
  at app//dk.ape.selenium.extensions.testrunner.TestRunnerExtension.beforeEach(TestRunnerExtension.java:27)
  at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeEachCallbacks$2(TestMethodTestDescriptor.java:163)
  at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.lambda$invokeBeforeMethodsOrCallbacksUntilExceptionOccurs$6(TestMethodTestDescriptor.java:199)
  at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
  at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeMethodsOrCallbacksUntilExceptionOccurs(TestMethodTestDescriptor.java:199)
  at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.invokeBeforeEachCallbacks(TestMethodTestDescriptor.java:162)
  at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:129)
  at app//org.junit.jupiter.engine.descriptor.TestMethodTestDescriptor.execute(TestMethodTestDescriptor.java:66)
  at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:151)
  at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
  at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
  at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
  at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
  at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
  at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
  at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
  at app//org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:185)
  at app//org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService.invokeAll(ForkJoinPoolHierarchicalTestExecutorService.java:129)
  at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
  at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
  at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
  at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
  at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
  at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
  at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
  at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
  at app//org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:185)
  at app//org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService.invokeAll(ForkJoinPoolHierarchicalTestExecutorService.java:129)
  at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$6(NodeTestTask.java:155)
  at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
  at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$8(NodeTestTask.java:141)
  at app//org.junit.platform.engine.support.hierarchical.Node.around(Node.java:137)
  at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.lambda$executeRecursively$9(NodeTestTask.java:139)
  at app//org.junit.platform.engine.support.hierarchical.ThrowableCollector.execute(ThrowableCollector.java:73)
  at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.executeRecursively(NodeTestTask.java:138)
  at app//org.junit.platform.engine.support.hierarchical.NodeTestTask.execute(NodeTestTask.java:95)
  at app//org.junit.platform.engine.support.hierarchical.ForkJoinPoolHierarchicalTestExecutorService$ExclusiveTask.compute(ForkJoinPoolHierarchicalTestExecutorService.java:185)
  at java.base@11.0.15/java.util.concurrent.RecursiveAction.exec(RecursiveAction.java:189)
  at java.base@11.0.15/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
  at java.base@11.0.15/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1020)
  at java.base@11.0.15/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1656)
  at java.base@11.0.15/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1594)
  at java.base@11.0.15/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
Caused by: java.lang.RuntimeException: NettyHttpHandler request execution error
  at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:76)
  at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
  at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
  at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49)
  at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
  at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
  at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:98)
  at org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:55)
  at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:120)
  at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:102)
  at org.openqa.selenium.remote.ProtocolHandshake.createSession(ProtocolHandshake.java:67)
  at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:156)
  at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)
  at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:551)
  ... 48 more
Caused by: java.util.concurrent.ExecutionException: java.util.concurrent.TimeoutException: Request timeout to selenium-hub-wea-staging.apps.c02u.paastools.dk/10.197.103.78:443 after 180000 ms
  at java.base/java.util.concurrent.CompletableFuture.reportGet(CompletableFuture.java:395)
  at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2022)
  at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:206)
  at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:59)
  ... 61 more
Caused by: java.util.concurrent.TimeoutException: Request timeout to selenium-hub-wea-staging.apps.c02u.paastools.dk/10.197.103.78:443 after 180000 ms
  at org.asynchttpclient.netty.timeout.TimeoutTimerTask.expire(TimeoutTimerTask.java:43)
  at org.asynchttpclient.netty.timeout.RequestTimeoutTimerTask.run(RequestTimeoutTimerTask.java:50)
  at io.netty.util.HashedWheelTimer$HashedWheelTimeout.run(HashedWheelTimer.java:715)
  at io.netty.util.concurrent.ImmediateExecutor.execute(ImmediateExecutor.java:34)
  at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:703)
  at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:790)
  at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:503)
  at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
  at java.base/java.lang.Thread.run(Thread.java:829)

@AndreasPetersen the timeout error in this issue does not happen in session creation, it happens when the session is already created. Can you please create a new issue for your situation?

diemol commented 2 years ago

still getting the concurrent timeout exception after updating to 4.2.1. Our current workaround is to use windows machines than linux until this is fixed. :) thank you for working on it :)

org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException
Build info: version: '4.2.1', revision: 'ac4d0fdd4a'
System info: host: 'ip-172-28-34-75', ip: '172.28.34.75', os.name: 'Linux', os.arch: 'amd64', os.version: '5.11.0-1022-aws', java.version: '11.0.13'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [b709ae86f606c86babdd11b9e05823a5, clickElement {id=e6dacac5-6c71-49b5-847d-1b47ea837c14}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 102.0.5005.61, chrome: {chromedriverVersion: 102.0.5005.61 (0e59bcc00cc4..., userDataDir: /tmp/.com.google.Chrome.1p47fJ}, goog:chromeOptions: {debuggerAddress: localhost:45719}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: LINUX, proxy: Proxy(), se:cdp: ws://localhost:45719/devtoo..., se:cdpVersion: 102.0.5005.61, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Element: [[ChromeDriver: chrome on LINUX (b709ae86f606c86babdd11b9e05823a5)] -> id: kc-login]
Session ID: b709ae86f606c86babdd11b9e05823a5
  at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:65)
  at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
  at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
  at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49)
  at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
  at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
  at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:98)
  at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:181)
  at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:167)
  at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:142)
  at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:551)
  at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:257)
  at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:78)
  at utils.ClickUtils.click(ClickUtils.java:36)
  at utils.ClickUtils.click(ClickUtils.java:44)
  at steps.straitsx.frontend.LoginStep.login(LoginStep.java:35)
  at stepdefinitions.straitsx.frontend.LoginStepDefinition.login(LoginStepDefinition.java:17)
  at ✽.user login using "STRAITSX_BIZ_UI_ID_COMMON" account(file:///home/circleci/project/src/test/resources/features/straitsx/frontend/Home.feature:9)
Caused by: java.util.concurrent.TimeoutException
  at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1886)
  at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2021)
  at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:206)
  at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:59)
  at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
  at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
  at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49)
  at org.openqa.selenium.remote.http.AddSeleniumUs2022-06-02 02:52:58.820 [TestNG-PoolService-3] DEBUG utils.SystemUtils#getConfig(line:87) - getting config of = take.screenshot.after.step

This is not a Grid log and there is no evidence that it works on Windows but not on Linux. Can you please provide evidence on this?

b-rogowski commented 2 years ago

I have a Selenium grid running on 3 Docker machines, with one machine the hub and 2 machines providing 7 Chrome and 7 Firefox browsers each. Everything runs very smoothly when I use 4.0.0-rc-2-20210930 (yes, it's really old!). If I go to a newer version. I get timeouts and Chrome sessions hanging around for ages - using only Firefox keeps the timeouts in check (but there's a reason we use both browsers....) grafik Changing to 4.1.2 or 4.2.1 didn't help, the latest version I got both browsers working properly is the one mentioned above. Here are some (slightly anonymized) logfiles: Grid Hub Log Grid Log Chrome Nodes Combined Grid Log Files of the Chrome Nodes on machine 1

Combined Grid Log Files of the Chrome Nodes on machine 2 Do you need more detailed logging / anything else?

diemol commented 2 years ago

@b-rogowski do you have a test to reproduce this? By checking the Node logs it seems it happens in every single one. How are you starting the Grid?

b-rogowski commented 2 years ago

When checking these logs, I was taken aback, because I do have some working tests on chrome and the screenshots to prove it 😆 Unfortunately, providing a simple test case to reproduce that is not me firing up our complete test suite might take some time, I hope I can get something on Friday. I start the grid with a simple grid-compose script, like this, only repeated 7 times with differing ports for the chromes, and then again 7 times for the firefoxes.

version: "3"
services:
  node-chrome_1:
    network_mode: host
    image: HARBOR_HOST/docker_hub/selenium/node-chrome:4.1.2-20220131
    restart: unless-stopped
    container_name: node-chrome_1
    ports:
      - "6551:5555"
      - "5901:5900"
    environment:
      - SE_EVENT_BUS_HOST=XXX.XXX.XXX.198
      - SE_EVENT_BUS_PUBLISH_PORT=4442
      - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
      - SE_NODE_HOST=YYY.YYY.YYY.129
      - SE_NODE_PORT=6551
    volumes:
      - /dev/shm:/dev/shm

Some more remarks:

b-rogowski commented 2 years ago

Still working on getting a minimal repdoducible test. I noticed while reading my frontend logfiles that the Chrome timeout exceptions always start with some elements that cannot be found...so I'm including that. At the moment, however, I'm still not getting any timeouts 😞

b-rogowski commented 2 years ago

It has nothing to do with screenshots or mobile emulation. It does, however, have to do with not finding elements on pages and also massively overloading the grid.

Here's a simple docker-compose file for a self-contained hub and 4 nodes, 2 on chrome, 2 on firefox (with an anonymized HARBOR_HOST):

services:
  node_1:
    image: $HARBOR_HOST/docker_hub/selenium/node-firefox:4.2.2-20220609
    shm_size: 2gb
    depends_on:
      - selenium-hub
    container_name: node_1
    ports:
      - "6551:5555"
      - "5901:5900"
    environment:
      - SE_EVENT_BUS_HOST=selenium-hub
      - SE_EVENT_BUS_PUBLISH_PORT=4442
      - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
    volumes:
      - /dev/shm:/dev/shm

  node_2:
    shm_size: 2gb
    depends_on:
      - selenium-hub
    image: $HARBOR_HOST/docker_hub/selenium/node-firefox:4.2.2-20220609
    container_name: node_2
    ports:
      - "6552:5555"
      - "5902:5900"
    environment:
      - SE_EVENT_BUS_HOST=selenium-hub
      - SE_EVENT_BUS_PUBLISH_PORT=4442
      - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
    volumes:
      - /dev/shm:/dev/shm

  node_3:
    image: $HARBOR_HOST/docker_hub/selenium/node-chrome:4.2.2-20220609
    shm_size: 2gb
    depends_on:
      - selenium-hub
    container_name: node_3
    ports:
      - "6553:5555"
      - "5903:5900"
    environment:
      - SE_EVENT_BUS_HOST=selenium-hub
      - SE_EVENT_BUS_PUBLISH_PORT=4442
      - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
    volumes:
      - /dev/shm:/dev/shm

  node_4:
    shm_size: 2gb
    depends_on:
      - selenium-hub
    image: $HARBOR_HOST/docker_hub/selenium/node-chrome:4.2.2-20220609
    container_name: node_4
    ports:
      - "6554:5555"
      - "5904:5900"
    environment:
      - SE_EVENT_BUS_HOST=selenium-hub
      - SE_EVENT_BUS_PUBLISH_PORT=4442
      - SE_EVENT_BUS_SUBSCRIBE_PORT=4443
    volumes:
      - /dev/shm:/dev/shm

  selenium-hub:
    image: $HARBOR_HOST/docker_hub/selenium/hub:4.2.2-20220609
    container_name: selenium-hub
    environment:
      GRID_MAX_SESSIONS: '30'
      GRID_DEBUG: 'true'
    ports:
      - "4442:4442"
      - "4443:4443"
      - "4444:4444"

This simple program does crash some nodes when I run it - if I run both browsers, firefox tends to crash first.

import org.openqa.selenium.MutableCapabilities;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.openqa.selenium.firefox.FirefoxOptions;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.testng.annotations.Test;

import java.net.URL;
import java.time.Duration;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.TimeUnit;

public class GridTestUtil {
    private static final String HUB_URL = "http://localhost:4444";
    public void runDriver(WebDriver driver){
        driver.manage().timeouts().pageLoadTimeout(Duration.ofSeconds(30));
        driver.manage().timeouts().implicitlyWait(Duration.ofSeconds(5));
        driver.get("https://www.selenium.dev");
        By search = By.className("DocSearch-Button-Placeholder");
        driver.findElement(search).click();
        driver.findElement(By.cssSelector("[enterkeyhint=search]")).sendKeys("grid");
        driver.navigate().refresh();
        driver.findElement(By.partialLinkText("Foobar")).click();
    }
    public void runTest(MutableCapabilities caps){
        WebDriver driver = null;
        try {
            driver = new RemoteWebDriver(new URL(HUB_URL), caps);
            runDriver(driver);
        }
        catch(Exception | Error e){
            System.out.println("PROBLEM " + e);
        }
        finally{
            if(driver != null){
                driver.close();
                driver.quit();
            }
        }
    }
    @Test
    public void testOverloadGrid() throws InterruptedException {
        ExecutorService tpool = Executors.newFixedThreadPool(24);
        for(int i = 0; i < 80; i++) {
            tpool.execute(() -> runTest(new ChromeOptions()));
            tpool.execute(() -> runTest(new FirefoxOptions()));
        }
        tpool.shutdown();
        tpool.awaitTermination(1, TimeUnit.HOURS);
    }
}

If I comment out the creation of firefox nodes, I can still get chrome to crash. The nodes seem to clear after about 5 minutes or so, but if you run tests massively parallel, that will still lead to a lot of falsely wobbly tests. If I change the docker images to version 4.0.0-rc-2-20210930, as described in my comment above, I do also get crashed browsers, but later.

I tried to keep the test program minimal, but also complex enough that the grid will reliably crash. It may not be realistic, but I think overloading the grid slightly led to similar problems (funnily enough, only with chrome - but we use chrome for testing the mobile resolution and some things may be harder to find) on our grid.

JulienBreton commented 2 years ago

@JulienBreton the log is confusing. What is being done in the test? I see several calls to /timeouts, then a session delete, and then more calls to /timeouts. Is there a way you can share a test that demonstrates this behavior?

@diemol this is the test I use to test the fix of this issue :

public void timeoutTest() {

  for (int i = 0; i < 2000; i++){

      System.out.println(i);

      driver.get("http://www.google.com");
      driver.getWindowHandle();
      driver.getCurrentUrl();
      driver.getTitle();
      driver.manage().timeouts().getScriptTimeout();
  }

}

I have created a Github repo with this test https://github.com/JulienBreton/demo_concurrent.TimeoutException I have added the logs files in it.

manu141 commented 2 years ago

@JulienBreton that's right ...even we are able to reproduce @diemol the same issue on IE Edge mode in selenium grid-HUB and NODE configuration and it's a huge blocker for us. As we run about 3000 tests during our regression time on and currently we went back to IE in some cases. We did try to limit nodes from 10 to 3 we saw some improvement but it happen at least on one node in 3 and tests fail on that node..no alternate solution we had to restart that test and node.

diemol commented 2 years ago

@JulienBreton thanks for the code sample.

@manu141 please do not hijack other issues without checking the context. This issue happens after the session has been created, I replied to your issue #10768, and marked the comment above as off-topic.

manu141 commented 2 years ago

@diemol I don't think I'm hijacking other issues and both are two different issues. This is the exact timeout exception we are getting with RemoteWebDriver when a session is created trying to do some action and it's retrying every 180 seconds for 5-8 times within the same session and/or sometimes even after the session ID is deleted. This takes up all the resources on the remote machine like CPU/Memory and it does not respond for a long time, we have to kill everything manually.

Note: not full logs but copied the exact timeout issue exception log for both hub and node that we are facing now. HUB: 15:55:20.493 DEBUG [TimeoutTimerTask.expire] - Request timeout to XX.XXX.XXX.XX/XX.XXX.XXX.XX:5555 after 180000 ms for NettyResponseFuture{currentRetry=0, isDone=0, isCancelled=0, asyncHandler=org.asynchttpclient.AsyncCompletionHandlerBase@4fa9f1f1, nettyRequest=org.asynchttpclient.netty.request.NettyRequest@521418ac, future=java.util.concurrent.CompletableFuture@6573f33[Not completed], uri=http://XX.XXX.XXX.XX:5555/session/d0937220-bc08-4f25-9599-367a682c2b85/element/a2d0024f-ac5d-40f8-ae9e-18f570149fad/click, keepAlive=true, redirectCount=0, timeoutsHolder=org.asynchttpclient.netty.timeout.TimeoutsHolder@35d0e81b, inAuth=0, touch=1654552340484} after 180009 ms 15:55:20.493 DEBUG [ChannelManager.closeChannel] - Closing Channel [id: 0xf803aaff, L:/XX.XXX.XXX.XX:55336 - R:/XX.XXX.XXX.XX:5555] 15:55:20.493 DEBUG [NettyRequestSender.abort] - Aborting Future NettyResponseFuture{currentRetry=0, isDone=0, isCancelled=0, asyncHandler=org.asynchttpclient.AsyncCompletionHandlerBase@4fa9f1f1, nettyRequest=org.asynchttpclient.netty.request.NettyRequest@521418ac, future=java.util.concurrent.CompletableFuture@6573f33[Not completed], uri=http://XX.XXX.XXX.XX:5555/session/d0937220-bc08-4f25-9599-367a682c2b85/element/a2d0024f-ac5d-40f8-ae9e-18f570149fad/click, keepAlive=true, redirectCount=0, timeoutsHolder=org.asynchttpclient.netty.timeout.TimeoutsHolder@35d0e81b, inAuth=0, touch=1654552340484}

15:55:20.493 DEBUG [NettyRequestSender.abort] - Request timeout to XX.XXX.XXX.XX/XX.XXX.XXX.XX:5555 after 180000 ms java.util.concurrent.TimeoutException: Request timeout to XX.XXX.XXX.XX/XX.XXX.XXX.XX:5555 after 180000 ms at org.asynchttpclient.netty.timeout.TimeoutTimerTask.expire(TimeoutTimerTask.java:43) at org.asynchttpclient.netty.timeout.RequestTimeoutTimerTask.run(RequestTimeoutTimerTask.java:50) at io.netty.util.HashedWheelTimer$HashedWheelTimeout.run(HashedWheelTimer.java:715) at io.netty.util.concurrent.ImmediateExecutor.execute(ImmediateExecutor.java:34) at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:703) at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:790) at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:503) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:748) 15:55:20.493 DEBUG [AsyncCompletionHandler.onThrowable] - Request timeout to XX.XXX.XXX.XX/XX.XXX.XXX.XX:5555 after 180000 ms java.util.concurrent.TimeoutException: Request timeout to XX.XXX.XXX.XX/XX.XXX.XXX.XX:5555 after 180000 ms at org.asynchttpclient.netty.timeout.TimeoutTimerTask.expire(TimeoutTimerTask.java:43) at org.asynchttpclient.netty.timeout.RequestTimeoutTimerTask.run(RequestTimeoutTimerTask.java:50) at io.netty.util.HashedWheelTimer$HashedWheelTimeout.run(HashedWheelTimer.java:715) at io.netty.util.concurrent.ImmediateExecutor.execute(ImmediateExecutor.java:34) at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:703) at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:790) at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:503) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:748)

NODE: 15:54:26.377 WARN [SpanWrappedHttpHandler.execute] - Unable to execute request: java.util.concurrent.TimeoutException Build info: version: '4.1.4', revision: '535d840ee2' System info: host: 'XXXXXXXXXX', ip: 'XX.XXX.XXX.XX', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_291' Driver info: driver.version: unknown org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException Build info: version: '4.1.4', revision: '535d840ee2' System info: host: 'XXXXXXXXXX', ip: 'XX.XXX.XXX.XX', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_291' Driver info: driver.version: unknown at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:65) at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42) at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56) at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49) at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42) at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56) at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:97) at org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:55) at org.openqa.selenium.grid.web.ReverseProxyHandler.execute(ReverseProxyHandler.java:92) at org.openqa.selenium.grid.node.ProtocolConvertingSession.execute(ProtocolConvertingSession.java:75) at org.openqa.selenium.grid.node.local.SessionSlot.execute(SessionSlot.java:125) at org.openqa.selenium.grid.node.local.LocalNode.executeWebDriverCommand(LocalNode.java:434) at org.openqa.selenium.grid.node.ForwardWebDriverCommand.execute(ForwardWebDriverCommand.java:35) at org.openqa.selenium.remote.http.Route$PredicatedRoute.handle(Route.java:373) at org.openqa.selenium.remote.http.Route.execute(Route.java:68) at org.openqa.selenium.remote.tracing.SpanWrappedHttpHandler.execute(SpanWrappedHttpHandler.java:86) at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64) at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336) at org.openqa.selenium.remote.http.Route.execute(Route.java:68) at org.openqa.selenium.grid.node.Node.execute(Node.java:240) at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336) at org.openqa.selenium.remote.http.Route.execute(Route.java:68) at org.openqa.selenium.remote.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:35) at org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44) at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64) at org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44) at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64) at org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.util.concurrent.TimeoutException at java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1784) at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1928) at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:206) at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:59) ... 32 more 15:54:26.377 DEBUG [SeleniumSpanExporter$1.lambda$export$1] - SpanData{spanContext=ImmutableSpanContext{traceId=53264e1b88c21cb87f6c07bbaacc5a92, spanId=bddcb9431f7d7be8, traceFlags=01, traceState=ArrayBasedTraceState{entries=[]}, remote=false, valid=true}, parentSpanContext=ImmutableSpanContext{traceId=53264e1b88c21cb87f6c07bbaacc5a92, spanId=eed883cf799477c5, traceFlags=01, traceState=ArrayBasedTraceState{entries=[]}, remote=true, valid=true}, resource=Resource{schemaUrl=https://opentelemetry.io/schemas/1.9.0, attributes={service.name="unknown_service:java", telemetry.sdk.language="java", telemetry.sdk.name="opentelemetry", telemetry.sdk.version="1.13.0"}}, instrumentationScopeInfo=InstrumentationScopeInfo{name=default, version=null, schemaUrl=null}, name=node.forward_command, kind=INTERNAL, startEpochNanos=1654552136355000000, endEpochNanos=1654552466381816432, attributes=AttributesMap{data={http.method=POST, error=true, span.kind=server, http.target=/session/9889041d-b2ec-4e73-826e-a7544c8b2ad6/window, random.key=279132a5-0615-4123-897b-2a02df698579}, capacity=128, totalAddedValues=5}, totalAttributeCount=5, events=[ImmutableEventData{name=exception, attributes={exception.message="Unable to execute request: java.util.concurrent.TimeoutException Build info: version: '4.1.4', revision: '535d840ee2' System info: host: 'XXXXXXXXXX', ip: 'XX.XXX.XXX.XX', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_291' Driver info: driver.version: unknown", exception.stacktrace="org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException Build info: version: '4.1.4', revision: '535d840ee2' System info: host: 'XXXXXXXXXX', ip: 'XX.XXX.XXX.XX', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_291' Driver info: driver.version: unknown at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:65) at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42) at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56) at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49) at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42) at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56) at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:97) at org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:55) at org.openqa.selenium.grid.web.ReverseProxyHandler.execute(ReverseProxyHandler.java:92) at org.openqa.selenium.grid.node.ProtocolConvertingSession.execute(ProtocolConvertingSession.java:75) at org.openqa.selenium.grid.node.local.SessionSlot.execute(SessionSlot.java:125) at org.openqa.selenium.grid.node.local.LocalNode.executeWebDriverCommand(LocalNode.java:434) at org.openqa.selenium.grid.node.ForwardWebDriverCommand.execute(ForwardWebDriverCommand.java:35) at org.openqa.selenium.remote.http.Route$PredicatedRoute.handle(Route.java:373) at org.openqa.selenium.remote.http.Route.execute(Route.java:68) at org.openqa.selenium.remote.tracing.SpanWrappedHttpHandler.execute(SpanWrappedHttpHandler.java:86) at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64) at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336) at org.openqa.selenium.remote.http.Route.execute(Route.java:68) at org.openqa.selenium.grid.node.Node.execute(Node.java:240) at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336) at org.openqa.selenium.remote.http.Route.execute(Route.java:68) at org.openqa.selenium.remote.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:35) at org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44) at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64) at org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44) at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64) at org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748) Caused by: java.util.concurrent.TimeoutException at java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1784) at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1928) at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:206) at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:59) ... 32 more ", exception.type="org.openqa.selenium.TimeoutException", http.flavor=1, http.handler_class="org.openqa.selenium.remote.http.Route$PredicatedRoute", http.host="XX.XXX.XXX.XX:4444", http.method="POST", http.request_content_length="54", http.scheme="HTTP", http.target="/session/9889041d-b2ec-4e73-826e-a7544c8b2ad6/window", http.user_agent="selenium/3.141.59 (java windows)"}, epochNanos=1654552466381470612, totalAttributeCount=11}], totalRecordedEvents=1, links=[], totalRecordedLinks=0, status=ImmutableStatusData{statusCode=ERROR, description=Kind: UNKNOWN Description:}, hasEnded=true} 15:54:26.377 WARN [SeleniumSpanExporter$1.lambda$export$0] - {"traceId": "53264e1b88c21cb87f6c07bbaacc5a92","eventTime": 1654552466381470612,"eventName": "exception","attributes": {"exception.message": "Unable to execute request: java.util.concurrent.TimeoutException\nBuild info: version: '4.1.4', revision: '535d840ee2'\nSystem info: host: 'XXXXXXXXXX', ip: 'XX.XXX.XXX.XX', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_291'\nDriver info: driver.version: unknown","exception.stacktrace": "org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException\nBuild info: version: '4.1.4', revision: '535d840ee2'\nSystem info: host: 'XXXXXXXXXX', ip: 'XX.XXX.XXX.XX', os.name: 'Windows Server 2016', os.arch: 'amd64', os.version: '10.0', java.version: '1.8.0_291'\nDriver info: driver.version: unknown\r\n\tat org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:65)\r\n\tat org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)\r\n\tat org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)\r\n\tat org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49)\r\n\tat org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)\r\n\tat org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)\r\n\tat org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:97)\r\n\tat org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:55)\r\n\tat org.openqa.selenium.grid.web.ReverseProxyHandler.execute(ReverseProxyHandler.java:92)\r\n\tat org.openqa.selenium.grid.node.ProtocolConvertingSession.execute(ProtocolConvertingSession.java:75)\r\n\tat org.openqa.selenium.grid.node.local.SessionSlot.execute(SessionSlot.java:125)\r\n\tat org.openqa.selenium.grid.node.local.LocalNode.executeWebDriverCommand(LocalNode.java:434)\r\n\tat org.openqa.selenium.grid.node.ForwardWebDriverCommand.execute(ForwardWebDriverCommand.java:35)\r\n\tat org.openqa.selenium.remote.http.Route$PredicatedRoute.handle(Route.java:373)\r\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\r\n\tat org.openqa.selenium.remote.tracing.SpanWrappedHttpHandler.execute(SpanWrappedHttpHandler.java:86)\r\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\r\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\r\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\r\n\tat org.openqa.selenium.grid.node.Node.execute(Node.java:240)\r\n\tat org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336)\r\n\tat org.openqa.selenium.remote.http.Route.execute(Route.java:68)\r\n\tat org.openqa.selenium.remote.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:35)\r\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\r\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\r\n\tat org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44)\r\n\tat org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64)\r\n\tat org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44)\r\n\tat java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)\r\n\tat java.util.concurrent.FutureTask.run(FutureTask.java:266)\r\n\tat java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)\r\n\tat java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)\r\n\tat java.lang.Thread.run(Thread.java:748)\r\nCaused by: java.util.concurrent.TimeoutException\r\n\tat java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1784)\r\n\tat java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1928)\r\n\tat org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:206)\r\n\tat org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:59)\r\n\t... 32 more\r\n","exception.type": "org.openqa.selenium.TimeoutException","http.flavor": 1,"http.handler_class": "org.openqa.selenium.remote.http.Route$PredicatedRoute","http.host": "XX.XXX.XXX.XX:4444","http.method": "POST","http.request_content_length": "54","http.scheme": "HTTP","http.target": "\u002fsession\u002f9889041d-b2ec-4e73-826e-a7544c8b2ad6\u002fwindow","http.user_agent": "selenium\u002f3.141.59 (java windows)"}}

15:54:26.444 DEBUG [TimeoutTimerTask.expire] - Request timeout to localhost/127.0.0.1:51258 after 330000 ms for NettyResponseFuture{currentRetry=0, isDone=0, isCancelled=0, asyncHandler=org.asynchttpclient.AsyncCompletionHandlerBase@7687d9ad, nettyRequest=org.asynchttpclient.netty.request.NettyRequest@33855919, future=java.util.concurrent.CompletableFuture@326decee[Not completed], uri=http://localhost:51258/session/9889041d-b2ec-4e73-826e-a7544c8b2ad6/window, keepAlive=true, redirectCount=0, timeoutsHolder=org.asynchttpclient.netty.timeout.TimeoutsHolder@2fc88c2, inAuth=0, touch=1654552136386} after 330058 ms 15:54:26.444 DEBUG [ChannelManager.closeChannel] - Closing Channel [id: 0xb913a709, L:/127.0.0.1:55283 - R:localhost/127.0.0.1:51258] 15:54:26.444 DEBUG [NettyRequestSender.abort] - Aborting Future NettyResponseFuture{currentRetry=0, isDone=0, isCancelled=0, asyncHandler=org.asynchttpclient.AsyncCompletionHandlerBase@7687d9ad, nettyRequest=org.asynchttpclient.netty.request.NettyRequest@33855919, future=java.util.concurrent.CompletableFuture@326decee[Not completed], uri=http://localhost:51258/session/9889041d-b2ec-4e73-826e-a7544c8b2ad6/window, keepAlive=true, redirectCount=0, timeoutsHolder=org.asynchttpclient.netty.timeout.TimeoutsHolder@2fc88c2, inAuth=0, touch=1654552136386}

15:54:26.444 FINEST [LoggingHandler.close] - [id: 0xb913a709, L:/127.0.0.1:55283 - R:localhost/127.0.0.1:51258] CLOSE 15:54:26.444 DEBUG [NettyRequestSender.abort] - Request timeout to localhost/127.0.0.1:51258 after 330000 ms java.util.concurrent.TimeoutException: Request timeout to localhost/127.0.0.1:51258 after 330000 ms at org.asynchttpclient.netty.timeout.TimeoutTimerTask.expire(TimeoutTimerTask.java:43) at org.asynchttpclient.netty.timeout.RequestTimeoutTimerTask.run(RequestTimeoutTimerTask.java:50) at io.netty.util.HashedWheelTimer$HashedWheelTimeout.run(HashedWheelTimer.java:715) at io.netty.util.concurrent.ImmediateExecutor.execute(ImmediateExecutor.java:34) at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:703) at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:790) at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:503) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:748) 15:54:26.444 DEBUG [AsyncCompletionHandler.onThrowable] - Request timeout to localhost/127.0.0.1:51258 after 330000 ms java.util.concurrent.TimeoutException: Request timeout to localhost/127.0.0.1:51258 after 330000 ms at org.asynchttpclient.netty.timeout.TimeoutTimerTask.expire(TimeoutTimerTask.java:43) at org.asynchttpclient.netty.timeout.RequestTimeoutTimerTask.run(RequestTimeoutTimerTask.java:50) at io.netty.util.HashedWheelTimer$HashedWheelTimeout.run(HashedWheelTimer.java:715) at io.netty.util.concurrent.ImmediateExecutor.execute(ImmediateExecutor.java:34) at io.netty.util.HashedWheelTimer$HashedWheelTimeout.expire(HashedWheelTimer.java:703) at io.netty.util.HashedWheelTimer$HashedWheelBucket.expireTimeouts(HashedWheelTimer.java:790) at io.netty.util.HashedWheelTimer$Worker.run(HashedWheelTimer.java:503) at io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30) at java.lang.Thread.run(Thread.java:748)

hope these logs help!

diemol commented 2 years ago

@manu141 they do not help because you are using an old version of Grid.

manu141 commented 2 years ago

@diemol yes we are using an older version because we are having another issue that is still open with 4.2.2 so we switched back to 4.1.4 as of today as its more stable in running IE Edge mode. I can give it a try with 4.2.2 and provide the new logs.

aprajapatii commented 2 years ago

Do we have any update on this issue? We are facing this issue in our project and we are stuck for a long time.

erdi commented 2 years ago

FWIW, I'm also observing random org.openqa.selenium.TimeoutExceptions being thrown when running Geb's test suite against dockerised Chrome and Firefox in CircleCI using Selenium 4.2.2. The same tests do not exhibit the issue if executed against HtmlUnitDriver or various drivers for real browsers at BrowserStack, Sauce Labs or LambdaTest. Some example stacktraces follow.

1:

Caused by: org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException
Build info: version: '4.2.2', revision: '683ccb65d6'
System info: host: '60b464b4caec', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-1004-aws', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [2261493a4ecd6a899d4d06a37163904a, switchToWindow {handle=CDwindow-5F32C8747B4090F761A5BE2A35D459B8}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 103.0.5060.53, chrome: {chromedriverVersion: 103.0.5060.53 (a1711811edd7..., userDataDir: /tmp/.com.google.Chrome.4KIPFY}, goog:chromeOptions: {debuggerAddress: localhost:39775}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: LINUX, proxy: Proxy(), se:cdp: ws://172.17.0.12:4444/sessi..., se:cdpEnabled: false, se:cdpVersion: 103.0.5060.53, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Session ID: 2261493a4ecd6a899d4d06a37163904a
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:65)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:98)
    at org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:55)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:181)
    at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:588)
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.window(RemoteWebDriver.java:1099)
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteTargetLocator.window(RemoteWebDriver.java:1105)
    at geb.Browser.switchToWindow(Browser.groovy:994)
    at geb.Browser.withWindow(Browser.groovy:760)
    at geb.Browser.withWindow(Browser.groovy:695)
    at geb.test.GebSpec.methodMissing(GebSpec.groovy:1)
    at geb.window.BasicWindowHandlingSpec.ensure exception is thrown for a non existing window passed to withWindow(BasicWindowHandlingSpec.groovy:75)
Caused by: java.util.concurrent.TimeoutException
    at java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1771)
    at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1915)
    at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:206)
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:59)
    ... 17 more

2:

org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException
Build info: version: '4.2.2', revision: '683ccb65d6'
System info: host: '5e3d1c247450', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-1004-aws', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [66617043b3ac2b75d000ab8b2a7cf414, getElementAttribute {id=ab36125f-559d-4a8e-b261-2461291cd067, name=type}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 103.0.5060.53, chrome: {chromedriverVersion: 103.0.5060.53 (a1711811edd7..., userDataDir: /tmp/.com.google.Chrome.7wT8Fc}, goog:chromeOptions: {debuggerAddress: localhost:33753}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: LINUX, proxy: Proxy(), se:cdp: ws://172.17.0.8:4444/sessio..., se:cdpEnabled: false, se:cdpVersion: 103.0.5060.53, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Element: [[[[RemoteWebDriver: chrome on LINUX (66617043b3ac2b75d000ab8b2a7cf414)] -> xpath: /*]] -> name: i1]
Session ID: 66617043b3ac2b75d000ab8b2a7cf414
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:65)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:98)
    at org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:55)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:181)
    at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:588)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:257)
    at org.openqa.selenium.remote.RemoteWebElement.getAttribute(RemoteWebElement.java:158)
    at geb.navigator.DefaultNavigator.setInputValue(DefaultNavigator.groovy:929)
    at geb.navigator.DefaultNavigator.setInputValues_closure56(DefaultNavigator.groovy:922)
    at groovy.lang.Closure.call(Closure.java:412)
    at geb.navigator.DefaultNavigator.setInputValues(DefaultNavigator.groovy:921)
    at geb.navigator.DefaultNavigator.propertyMissing(DefaultNavigator.groovy:833)
    at groovy.lang.GroovyObject.setProperty(GroovyObject.java:61)
    at geb.navigator.FormControlSpec.checkbox(FormControlSpec.groovy:116)
Caused by: java.util.concurrent.TimeoutException
    at java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1771)
    at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1915)
    at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:206)
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:59)
    ... 19 more

3:

org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException
Build info: version: '4.2.2', revision: '683ccb65d6'
System info: host: 'a11cfb8e6f50', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-1004-aws', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [827021802ee5956c79627f61e58f083b, get {url=http://host.testcontainers.internal:39641/}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 103.0.5060.53, chrome: {chromedriverVersion: 103.0.5060.53 (a1711811edd7..., userDataDir: /tmp/.com.google.Chrome.Dv7AN3}, goog:chromeOptions: {debuggerAddress: localhost:45171}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: LINUX, proxy: Proxy(), se:cdp: ws://172.17.0.8:4444/sessio..., se:cdpEnabled: false, se:cdpVersion: 103.0.5060.53, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Session ID: 827021802ee5956c79627f61e58f083b
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:65)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:98)
    at org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:55)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:181)
    at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:588)
    at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:351)
    at geb.Browser.go(Browser.groovy:508)
    at geb.test.GebSpec.methodMissing(GebSpec.groovy:1)
    at geb.test.GebSpecWithCallbackServer.html(GebSpecWithCallbackServer.groovy:42)
    at geb.navigator.NavigatorClickSpec.click call returns receiver for parameters: #clickParams(NavigatorClickSpec.groovy:32)
Caused by: java.util.concurrent.TimeoutException
    at java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1771)
    at java.util.concurrent.CompletableFuture.get(CompletableFuture.java:1915)
    at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:206)
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:59)
    ... 15 more

As you can see this happens for various webdriver commands.

Additionally I've also once seen a slightly different problem (no content rather than timeout) in the same circumstances (dockerised browsers driven in CircleCI) which feels like it could have the same cause (apologies if it doesn't) so I'm also sharing the stacktrace:

org.openqa.selenium.WebDriverException: Expected to read a START_MAP but instead have: END. Last 0 characters read: 
Build info: version: '4.2.2', revision: '683ccb65d6'
System info: host: 'a018cf17faa9', ip: '172.17.0.3', os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-1004-aws', java.version: '11.0.15'
Driver info: driver.version: unknown
Build info: version: '4.2.2', revision: '683ccb65d6'
System info: host: '06d8db4d1834', ip: '172.17.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.15.0-1004-aws', java.version: '1.8.0_191'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [275faf2b-0a97-4aa9-92e7-7db86e08eeca, findElements {using=css selector, value=a}]
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 101.0.1, moz:accessibilityChecks: false, moz:buildID: 20220608170832, moz:debuggerAddress: localhost:46350, moz:firefoxOptions: {}, moz:geckodriverVersion: 0.31.0, moz:headless: false, moz:processID: 144, moz:profile: /tmp/rust_mozprofile2bTTkh, moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, pageLoadStrategy: normal, platformName: LINUX, platformVersion: 5.15.0-1004-aws, proxy: Proxy(), se:cdp: ws://172.17.0.3:4444/sessio..., se:cdpVersion: 85.0, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify}
Session ID: 275faf2b-0a97-4aa9-92e7-7db86e08eeca
    at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.createException(W3CHttpResponseCodec.java:200)
    at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:133)
    at org.openqa.selenium.remote.codec.w3c.W3CHttpResponseCodec.decode(W3CHttpResponseCodec.java:53)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:184)
    at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:588)
    at org.openqa.selenium.remote.ElementLocation$ElementFinder$2.findElements(ElementLocation.java:179)
    at org.openqa.selenium.remote.ElementLocation.findElements(ElementLocation.java:102)
    at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:421)
    at org.openqa.selenium.remote.RemoteWebDriver.findElements(RemoteWebDriver.java:413)
    at geb.navigator.SearchContextBasedBasicLocator.elementsSupplier_closure8$_closure12(SearchContextBasedBasicLocator.groovy:199)
    at groovy.lang.Closure.call(Closure.java:412)
    at groovy.lang.Closure.call(Closure.java:428)
    at geb.navigator.SearchContextBasedBasicLocator.elementsSupplier_closure8(SearchContextBasedBasicLocator.groovy:199)
    at groovy.lang.Closure.call(Closure.java:412)
    at geb.navigator.SearchContextBasedBasicLocator.toNavigator(SearchContextBasedBasicLocator.groovy:223)
    at geb.navigator.SearchContextBasedBasicLocator.find(SearchContextBasedBasicLocator.groovy:186)
    at geb.navigator.SearchContextBasedBasicLocator.find(SearchContextBasedBasicLocator.groovy:55)
    at geb.navigator.DefaultLocator.find(DefaultLocator.groovy:22)
    at geb.navigator.DefaultLocator.find(DefaultLocator.groovy:31)
    at geb.navigator.DefaultLocator.find(DefaultLocator.groovy:41)
    at geb.content.NavigableSupport.$(NavigableSupport.groovy:77)
    at geb.Page.$(Page.groovy:131)
    at geb.Browser.methodMissing(Browser.groovy:229)
    at geb.test.GebSpec.methodMissing(GebSpec.groovy:1)
    at geb.window.BaseWindowHandlingSpec.openWindow(BaseWindowHandlingSpec.groovy:84)
    at geb.window.BasicWindowHandlingSpec.ensure original context is preserved after a call to withNewWindow_closure9(BasicWindowHandlingSpec.groovy:103)
    at geb.window.BasicWindowHandlingSpec.ensure original context is preserved after a call to withNewWindow_closure9(BasicWindowHandlingSpec.groovy)
    at geb.Browser.executeNewWindowOpening(Browser.groovy:1044)
    at geb.Browser.withNewWindow(Browser.groovy:787)
    at geb.Browser.withNewWindow(Browser.groovy:818)
    at geb.test.GebSpec.methodMissing(GebSpec.groovy:1)
    at geb.window.BasicWindowHandlingSpec.ensure original context is preserved after a call to withNewWindow(BasicWindowHandlingSpec.groovy:103)
jgfmachado commented 2 years ago

Any updates on this issue? Have someone else found a solution?

bgrgincic commented 2 years ago

@jgfmachado there was a workaround earlier in the thread https://github.com/SeleniumHQ/selenium/issues/9528#issuecomment-1002776116

jgfmachado commented 2 years ago

@bgrgincic thank you, I just don't understand where and how do I implement his solution.

bgrgincic commented 2 years ago

@jgfmachado that entire code should replace your current WebDriver instantiation, as you can see the last line is actually returning the WebDriver instance which you can use in all your Selenium actions.

remoteWebDriver = new RemoteWebDriver(tracedCommandExecutor, getChromeOptions(runTimeProps));

Only thing you need to forward to this method is some chrome options/capabilities that you usually use and setup a proper Selenium Grid URL a few lines before.

HemanthRajaSudhakar commented 2 years ago

We're also seeing 5-10% failures due to this issue.

Here's @Cybermaxke's spectacular workaround verbosely written in Java. Would really prefer this to just be configurable or fixed.

RetryRequest retryRequest = new RetryRequest();

Field readTimeoutPolicyField = retryRequest.getClass().getDeclaredField("readTimeoutPolicy");
readTimeoutPolicyField.setAccessible(true);

RetryPolicy<HttpResponse> readTimeoutPolicy =
      new RetryPolicy<HttpResponse>()
              .handle(TimeoutException.class)
              .withBackoff(1, 4, ChronoUnit.SECONDS)
              .withMaxRetries(3)
              .withMaxDuration(Duration.ofSeconds(300))
              .onRetry(e -> CustomLog.info(String.format(
                      "Read timeout #%s. Retrying.",
                      e.getAttemptCount())));

FieldUtils.removeFinalModifier(readTimeoutPolicyField);
readTimeoutPolicyField.set(retryRequest, readTimeoutPolicy);

Filter filter = new AddSeleniumUserAgent().andThen(retryRequest);
ClientConfig config = ClientConfig
      .defaultConfig()
      .baseUrl(new URL(seleniumGridUrl))
      .readTimeout(Duration.ofSeconds(90))
      .withFilter(filter);
OpenTelemetryTracer tracer = OpenTelemetryTracer.getInstance();
HttpClient.Factory httpClientFactory = HttpClient.Factory.createDefault();
TracedHttpClient.Factory tracedHttpClientFactory = new TracedHttpClient.Factory(
      tracer,
      httpClientFactory);
CommandExecutor executor = new HttpCommandExecutor(Collections.emptyMap(), config, tracedHttpClientFactory);
TracedCommandExecutor tracedCommandExecutor = new TracedCommandExecutor(executor, tracer);
remoteWebDriver = new RemoteWebDriver(tracedCommandExecutor, getChromeOptions(runTimeProps));

@Cybermaxke @asan127 When I try to paste this workaround in my project, I see 2 errors

  1. 'RetryPolicy' is abstract; cannot be instantiated and CustomLog & getAttemptCount throws Cannot resolve symbol 'CustomLog' and 'getAttemptCount' errors
  2. FieldUtils class seems to have no such method name removeFinalModifier, which was used above

Please guide me over implementing this workaround Thanks! image

95nagyd commented 2 years ago

(caution: I only tested it with two test cases mentioned below. I am only writing this comment, because the workaround's implementation wasn't 100% obvious for me, and I saw @HemanthRajaSudhakar(https://github.com/SeleniumHQ/selenium/issues/9528#issuecomment-1203101100) ask for help about it. There might be better approach to implement the workaround, sorry for mistakes, please correct me if I am wrong!)

@Cybermaxke(https://github.com/SeleniumHQ/selenium/issues/9528#issuecomment-998105828) @asan127(https://github.com/SeleniumHQ/selenium/issues/9528#issuecomment-1002776116) workaround in Java

Used dependencies: webdrivermanager 5.2.2 selenium 4.3.0 apache commons lang3 3.12.0 dev.failsafe 3.2.4 selenium/hub 4.3.0 selenium/node-chrome 4.3.0

Tested with @JulienBreton(https://github.com/SeleniumHQ/selenium/issues/9528#issuecomment-1153925497) code sample with two test cases running parallel on chrome nodes. The output of the parallel execution clearly shows, that the workaround does the trick:

    253
    254
    255
    256
    257
    Read timeout #1. Retrying.
    268
    258
    269
    259

Import list just to make sure, that everyone will import the used classes from the correct package: import dev.failsafe.RetryPolicy; import org.apache.commons.lang3.reflect.FieldUtils; import org.openqa.selenium.Capabilities; import org.openqa.selenium.TimeoutException; import org.openqa.selenium.remote.CommandExecutor; import org.openqa.selenium.remote.HttpCommandExecutor; import org.openqa.selenium.remote.RemoteWebDriver; import org.openqa.selenium.remote.TracedCommandExecutor; import org.openqa.selenium.remote.http.*; import org.openqa.selenium.remote.tracing.TracedHttpClient; import org.openqa.selenium.remote.tracing.opentelemetry.OpenTelemetryTracer;

import java.lang.reflect.Field; import java.net.URL; import java.time.Duration; import java.time.temporal.ChronoUnit; import java.util.Collections;

public static RemoteWebDriver getRemoteDriver(URL remoteHostUrl, Capabilities capabilities) {
    RetryRequest retryRequest = new RetryRequest();

    Field readTimeoutPolicyField;
    try {
        readTimeoutPolicyField = retryRequest.getClass().getDeclaredField("readTimeoutPolicy");
    } catch (NoSuchFieldException e) {
        throw new RuntimeException(e);
    }
    readTimeoutPolicyField.setAccessible(true);

    RetryPolicy<Object> readTimeoutPolicy =
            RetryPolicy.builder()
                    .handle(TimeoutException.class)
                    .withBackoff(1, 4, ChronoUnit.SECONDS)
                    .withMaxRetries(3)
                    .withMaxDuration(Duration.ofSeconds(300))
                    .onRetry(e -> System.out.printf(
                            "Read timeout #%s. Retrying.%n",
                            e.getAttemptCount()))
                    .build();

    FieldUtils.removeFinalModifier(readTimeoutPolicyField);
    try {
        readTimeoutPolicyField.set(retryRequest, readTimeoutPolicy);
    } catch (IllegalAccessException e) {
        throw new RuntimeException(e);
    }

    Filter filter = new AddSeleniumUserAgent().andThen(retryRequest);
    ClientConfig config = ClientConfig
            .defaultConfig()
            .baseUrl(remoteHostUrl)
            .readTimeout(Duration.ofSeconds(90))
            .withFilter(filter);
    OpenTelemetryTracer tracer = OpenTelemetryTracer.getInstance();
    HttpClient.Factory httpClientFactory = HttpClient.Factory.createDefault();
    TracedHttpClient.Factory tracedHttpClientFactory = new TracedHttpClient.Factory(
            tracer,
            httpClientFactory);
    CommandExecutor executor = new HttpCommandExecutor(Collections.emptyMap(), config, tracedHttpClientFactory);
    TracedCommandExecutor tracedCommandExecutor = new TracedCommandExecutor(executor, tracer);
    return new RemoteWebDriver(tracedCommandExecutor, capabilities);
}
mghantous commented 2 years ago

Does anyone have a port of this workaround for python? I was hoping for a fix or a feature to enable this in the core codebase.

doublebon commented 2 years ago

I was getting a similar error when running tests with using a set:

  1. Java 17
  2. Selenide (v6.6.6) wrapper over Selenium
  3. @dataProvider(parallel = true) from TestNg
  4. <parallel>methods</parallel> && <threadCount>10</threadCount> at maven-surefire-plugin

parallel = true in dataProvider somehow strangely works together with <parallel>methods</parallel> from maven-surefire-plugin. The problem was solved by setting a limit on the number of threads for dataProvider parallel

@BeforeClass
    public void BeforeClass(ITestContext context){
       context.getCurrentXmlTest().getSuite().setDataProviderThreadCount(9);
}
pavelbelonosov commented 2 years ago

Facing the same issue with dockerized chrome/standalone: 1) Fluentlenium (4.8.0) 2) Chrome (selenium/standalone-chrome:4.4.0-20220812) 3) Java 11

Using SE_SESSION_REQUEST_TIMEOUT value from 300 to 3600 randomly reduces number of test failures.

Fluentlenium configuration: @FluentConfiguration(webDriver = "remote", remoteUrl = "http://chrome:4444", capabilities = "{\"goog:chromeOptions\": {\"args\": [" + "\"headless\"," + "\"disable-gpu\"," + "\"window-size=1920,1080\"]}}")

Error log:

apptest | 2022-09-05 19:48:08.269 INFO 70 --- [ null to remote] o.o.selenium.remote.ProtocolHandshake : Detected dialect: W3C chrome_1 | 19:53:11.682 WARN [SpanWrappedHttpHandler.execute] - Unable to execute request: java.util.concurrent.TimeoutException chrome_1 | Build info: version: '4.4.0', revision: 'e5c75ed026a' chrome_1 | System info: host: '52f69ffaa7e1', ip: '172.18.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.16.3-microsoft-standard-WSL2', java.version: '11.0.16' chrome_1 | Driver info: driver.version: unknown chrome_1 | org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException chrome_1 | Build info: version: '4.4.0', revision: 'e5c75ed026a' chrome_1 | System info: host: '52f69ffaa7e1', ip: '172.18.0.2', os.name: 'Linux', os.arch: 'amd64', os.version: '5.10.16.3-microsoft-standard-WSL2', java.version: '11.0.16' chrome_1 | Driver info: driver.version: unknown chrome_1 | at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:65) chrome_1 | at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42) chrome_1 | at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56) chrome_1 | at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49) chrome_1 | at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42) chrome_1 | at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56) chrome_1 | at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:98) chrome_1 | at org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:55) chrome_1 | at org.openqa.selenium.grid.web.ReverseProxyHandler.execute(ReverseProxyHandler.java:92) chrome_1 | at org.openqa.selenium.grid.node.ProtocolConvertingSession.execute(ProtocolConvertingSession.java:75) chrome_1 | at org.openqa.selenium.grid.node.local.SessionSlot.execute(SessionSlot.java:125) chrome_1 | at org.openqa.selenium.grid.node.local.LocalNode.executeWebDriverCommand(LocalNode.java:448) chrome_1 | at org.openqa.selenium.grid.node.ForwardWebDriverCommand.execute(ForwardWebDriverCommand.java:35) chrome_1 | at org.openqa.selenium.remote.http.Route$PredicatedRoute.handle(Route.java:373) chrome_1 | at org.openqa.selenium.remote.http.Route.execute(Route.java:68) chrome_1 | at org.openqa.selenium.remote.tracing.SpanWrappedHttpHandler.execute(SpanWrappedHttpHandler.java:86) chrome_1 | at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64) chrome_1 | at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336) chrome_1 | at org.openqa.selenium.remote.http.Route.execute(Route.java:68) chrome_1 | at org.openqa.selenium.grid.node.Node.execute(Node.java:240) chrome_1 | at org.openqa.selenium.grid.web.CombinedHandler.execute(CombinedHandler.java:59) chrome_1 | at org.openqa.selenium.grid.web.RoutableHttpClientFactory$1.execute(RoutableHttpClientFactory.java:72) chrome_1 | at org.openqa.selenium.grid.web.ReverseProxyHandler.execute(ReverseProxyHandler.java:92) chrome_1 | at org.openqa.selenium.grid.router.HandleSession.execute(HandleSession.java:122) chrome_1 | at org.openqa.selenium.remote.http.Route$PredicatedRoute.handle(Route.java:373) chrome_1 | at org.openqa.selenium.remote.http.Route.execute(Route.java:68) chrome_1 | at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336) chrome_1 | at org.openqa.selenium.remote.http.Route.execute(Route.java:68) chrome_1 | at org.openqa.selenium.grid.router.Router.execute(Router.java:91) chrome_1 | at org.openqa.selenium.grid.web.EnsureSpecCompliantResponseHeaders.lambda$apply$0(EnsureSpecCompliantResponseHeaders.java:34) chrome_1 | at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64) chrome_1 | at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336) chrome_1 | at org.openqa.selenium.remote.http.Route.execute(Route.java:68) chrome_1 | at org.openqa.selenium.remote.http.Route$CombinedRoute.handle(Route.java:336) chrome_1 | at org.openqa.selenium.remote.http.Route.execute(Route.java:68) chrome_1 | at org.openqa.selenium.remote.AddWebDriverSpecHeaders.lambda$apply$0(AddWebDriverSpecHeaders.java:35) chrome_1 | at org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44) chrome_1 | at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64) chrome_1 | at org.openqa.selenium.remote.ErrorFilter.lambda$apply$0(ErrorFilter.java:44) chrome_1 | at org.openqa.selenium.remote.http.Filter$1.execute(Filter.java:64) chrome_1 | at org.openqa.selenium.netty.server.SeleniumHandler.lambda$channelRead0$0(SeleniumHandler.java:44) chrome_1 | at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) chrome_1 | at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) chrome_1 | at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) chrome_1 | at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) chrome_1 | at java.base/java.lang.Thread.run(Thread.java:829) chrome_1 | Caused by: java.util.concurrent.TimeoutException chrome_1 | at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1886) chrome_1 | at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2021) chrome_1 | at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:206) chrome_1 | at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:59) chrome_1 | ... 45 more

Update: after upgarding Spring Boot (from 2.4 to 2.5.6), upgrading java version (from 11 to 17) and swithcing to latest chrome image problem is totally gone.

karolszczapa commented 2 years ago

The workaround above doesn't work on java 12+ (because final modifier is being removed). If you use a newer java this workaround would work for every version of java:

package config.driver;

import dev.failsafe.Failsafe;
import dev.failsafe.Fallback;
import dev.failsafe.RetryPolicy;
import org.openqa.selenium.TimeoutException;
import org.openqa.selenium.remote.http.Filter;
import org.openqa.selenium.remote.http.HttpHandler;
import org.openqa.selenium.remote.http.HttpResponse;
import org.openqa.selenium.remote.http.RetryRequest;

import java.lang.reflect.Field;
import java.time.Duration;
import java.time.temporal.ChronoUnit;
import java.util.concurrent.atomic.AtomicReference;

public class RetryRequestWithNewRetryPolicy implements Filter {
  private static final AtomicReference<HttpResponse> fallBackResponse = new AtomicReference<>();
  private static final Fallback<Object> fallback = Fallback.of(fallBackResponse::get);
  private static final RetryPolicy<Object> serverErrorPolicy = getStaticRetryPolicyFromRetryRequest("serverErrorPolicy");
  private static final RetryPolicy<Object> connectionFailurePolicy = getStaticRetryPolicyFromRetryRequest("connectionFailurePolicy");

  private static final RetryPolicy<Object> readTimeoutPolicy =
          RetryPolicy.builder()
                  .handle(TimeoutException.class)
                  .withBackoff(1, 4, ChronoUnit.SECONDS)
                  .withMaxRetries(3)
                  .withMaxDuration(Duration.ofSeconds(300))
                  .build();

  @SuppressWarnings("unchecked")
  private static RetryPolicy<Object> getStaticRetryPolicyFromRetryRequest(String name){
    final RetryRequest retryRequest = new RetryRequest();
    Field connectionFailurePolicy;
    try {
      connectionFailurePolicy = retryRequest.getClass().getDeclaredField(name);
    } catch (NoSuchFieldException e) {
      throw new RuntimeException(e);
    }
    try {
      connectionFailurePolicy.setAccessible(true);
      return (RetryPolicy<Object>) connectionFailurePolicy.get(retryRequest);
    } catch (IllegalAccessException e) {
      throw new RuntimeException(e);
    }
  }

  @Override
  public HttpHandler apply(HttpHandler next) {
    return req -> Failsafe
      .with(fallback)
      .compose(serverErrorPolicy)
      .compose(readTimeoutPolicy)
      .compose(connectionFailurePolicy)
      .get(() -> next.execute(req));
  }
}
package config.driver;

import java.net.URL;
import java.time.Duration;
import java.util.Collections;

import org.openqa.selenium.Capabilities;
import org.openqa.selenium.remote.CommandExecutor;
import org.openqa.selenium.remote.HttpCommandExecutor;
import org.openqa.selenium.remote.RemoteWebDriver;
import org.openqa.selenium.remote.TracedCommandExecutor;
import org.openqa.selenium.remote.http.AddSeleniumUserAgent;
import org.openqa.selenium.remote.http.ClientConfig;
import org.openqa.selenium.remote.http.Filter;
import org.openqa.selenium.remote.http.HttpClient;
import org.openqa.selenium.remote.tracing.TracedHttpClient;
import org.openqa.selenium.remote.tracing.opentelemetry.OpenTelemetryTracer;

public class RemoteWebDriverFactory {

    public static RemoteWebDriver getRemoteDriver(URL remoteHostUrl, Capabilities capabilities) {
        RetryRequestWithNewRetryPolicy retryPolicy = new RetryRequestWithNewRetryPolicy();

        Filter filter = new AddSeleniumUserAgent().andThen(retryPolicy);
        ClientConfig config = ClientConfig
            .defaultConfig()
            .baseUrl(remoteHostUrl)
            .readTimeout(Duration.ofSeconds(90))
            .withFilter(filter);
        OpenTelemetryTracer tracer = OpenTelemetryTracer.getInstance();
        HttpClient.Factory httpClientFactory = HttpClient.Factory.createDefault();
        TracedHttpClient.Factory tracedHttpClientFactory = new TracedHttpClient.Factory(
            tracer,
            httpClientFactory);
        CommandExecutor executor = new HttpCommandExecutor(Collections.emptyMap(), config, tracedHttpClientFactory);
        TracedCommandExecutor tracedCommandExecutor = new TracedCommandExecutor(executor, tracer);
        return new RemoteWebDriver(tracedCommandExecutor, capabilities);
    }
}
marcioveiga16 commented 2 years ago

Hello everyone, even with your provided solution karolszczapa, i still get too much random TimeoutExceptions, the problem it's not deterministic, it randomly hangs trying to execute new RemoteWebDriver(new URL(myUrl), remoteOptions).

Are there any other solutions ?

Thanks in advance.

therealdjryan commented 2 years ago

Might this be resolved with Selenium 4.5 and jdkhttp?

titusfortner commented 2 years ago

Yes, please try the new http client with Selenium 4.5 and let us know. https://www.selenium.dev/blog/2022/using-java11-httpclient/

hamaarouf commented 2 years ago

In my case was an internet connection problem; when I changed my wifi connection i got rid of that error

surli commented 2 years ago

Hi, joining this discussion as we're also hitting this bug in various cases, even with calls to implicitlyWait for setting the timeout. Example of stacktraces:

Caused by: org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException
Build info: version: '4.5.0', revision: 'fe167b119a'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '4.19.0-13-cloud-amd64', java.version: '11.0.6'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [2675372f-5a5c-4f3b-a86a-05a1e76d8069, setTimeout {implicit=10000}]
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 105.0.2, moz:accessibilityChecks: false, moz:buildID: 20221003135607, moz:debuggerAddress: 127.0.0.1:33006, moz:firefoxOptions: {prefs: {dom.disable_beforeunload: false}}, moz:geckodriverVersion: 0.31.0, moz:headless: false, moz:platformVersion: 4.19.0-13-cloud-amd64, moz:processID: 139, moz:profile: /tmp/rust_mozprofileVWqZ1V, moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, moz:windowless: false, pageLoadStrategy: normal, platformName: LINUX, proxy: Proxy(), se:cdp: ws://172.17.0.5:4444/sessio..., se:cdpVersion: 85.0, se:noVncPort: 7900, se:vnc: ws://172.17.0.5:4444/sessio..., se:vncEnabled: true, se:vncLocalAddress: ws://172.17.0.5:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: ignore}
Session ID: 2675372f-5a5c-4f3b-a86a-05a1e76d8069
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:65)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:99)
    at org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:55)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:181)
    at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:547)
    at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteTimeouts.implicitlyWait(RemoteWebDriver.java:858)
    at org.xwiki.test.ui.XWikiWebDriver.setDriverImplicitWait(XWikiWebDriver.java:248)

or on a more standard get call:

org.openqa.selenium.TimeoutException: 
java.util.concurrent.TimeoutException
Build info: version: '4.5.0', revision: 'fe167b119a'
System info: os.name: 'Linux', os.arch: 'amd64', os.version: '4.19.0-16-cloud-amd64', java.version: '11.0.6'
Driver info: org.openqa.selenium.remote.RemoteWebDriver
Command: [019170d3-7c8e-40bc-8342-18791c50dfc1, get {url=[http://xwikiweb:8080/xwiki/bin/register/xwiki/Register}]](http://xwikiweb:8080/xwiki/bin/register/xwiki/Register%7D])
Capabilities {acceptInsecureCerts: true, browserName: firefox, browserVersion: 105.0.2, moz:accessibilityChecks: false, moz:buildID: 20221003135607, moz:debuggerAddress: 127.0.0.1:40289, moz:firefoxOptions: {prefs: {dom.disable_beforeunload: false}}, moz:geckodriverVersion: 0.31.0, moz:headless: false, moz:platformVersion: 4.19.0-16-cloud-amd64, moz:processID: 139, moz:profile: /tmp/rust_mozprofileDYrBHB, moz:shutdownTimeout: 60000, moz:useNonSpecCompliantPointerOrigin: false, moz:webdriverClick: true, moz:windowless: false, pageLoadStrategy: normal, platformName: LINUX, proxy: Proxy(), se:cdp: ws://172.17.0.7:4444/sessio..., se:cdpVersion: 85.0, se:noVncPort: 7900, se:vnc: ws://172.17.0.7:4444/sessio..., se:vncEnabled: true, se:vncLocalAddress: ws://172.17.0.7:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: ignore}
Session ID: 019170d3-7c8e-40bc-8342-18791c50dfc1
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:65)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:99)
    at org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:55)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:181)
    at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:547)
    at org.openqa.selenium.remote.RemoteWebDriver.get(RemoteWebDriver.java:310)
    at org.xwiki.test.ui.XWikiWebDriver.get(XWikiWebDriver.java:633)
    at org.xwiki.test.ui.TestUtils.gotoPage(TestUtils.java:713)

This kind of errors always seem to happen randomly. In our case we're running our tests on docker using TestContainer.

testermarcinf commented 2 years ago

Looks like I have a similar problem. My test:

import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;
import org.openqa.selenium.chrome.ChromeOptions;
import org.testng.annotations.Test;

public class Test123 {

    @Test
    public void test() {
        ChromeOptions options = new ChromeOptions();
        options.addArguments("--incognito");
        options.addArguments("--lang=" + "pl_PL");
        System.setProperty("webdriver.chrome.driver", "C:\\tzqa\\chromedriver.exe");
        WebDriver driver = new ChromeDriver(options);
        driver.get("https://bezgotowki.pl/odbierz-terminal/");
        driver.findElement(By.xpath("//main//*[contains(text(),'Smart-POS')]/..//button[text()='+']")).click();
        driver.findElement(By.id("mainOrderButton")).click();
        driver.findElement(By.xpath("//a[contains(text(),'Dalej')]")).click();
    }

}

Project maven, pom:

    <properties>
        <maven.compiler.source>11</maven.compiler.source>
        <maven.compiler.target>11</maven.compiler.target>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <testng.version>7.5</testng.version>
        <selenium.version>4.5.0</selenium.version>

        <aspectj.version>1.9.6</aspectj.version>
        <maven.surefire.plugin.version>3.0.0-M7</maven.surefire.plugin.version>
        <allure.maven.version>2.10.0</allure.maven.version>
        <allure.testng.version>2.19.0</allure.testng.version>
        <maven.compiler.plugin.version>3.10.1</maven.compiler.plugin.version>
        <exec.maven.plugin.version>1.6.0</exec.maven.plugin.version>
    </properties>

Logs:

Starting ChromeDriver 106.0.5249.61 (511755355844955cd3e264779baf0dd38212a4d0-refs/branch-heads/5249@{#569}) on port 53366
Only local connections are allowed.
Please see https://chromedriver.chromium.org/security-considerations for suggestions on keeping ChromeDriver safe.
ChromeDriver was started successfully.
paź 17, 2022 4:19:56 PM org.openqa.selenium.remote.ProtocolHandshake createSession
INFO: Detected upstream dialect: W3C
paź 17, 2022 4:19:56 PM org.openqa.selenium.devtools.CdpVersionFinder findNearestMatch
INFO: Found exact CDP implementation for version 106

org.openqa.selenium.TimeoutException: java.util.concurrent.TimeoutException
Build info: version: '4.5.0', revision: 'fe167b119a'
System info: os.name: 'Windows 10', os.arch: 'amd64', os.version: '10.0', java.version: '11.0.16'
Driver info: org.openqa.selenium.chrome.ChromeDriver
Command: [ae9d19eb2960eab4ec35715c75dd7501, clickElement {id=f4f4cebd-f2fb-49a1-9014-2b99811c361c}]
Capabilities {acceptInsecureCerts: false, browserName: chrome, browserVersion: 106.0.5249.119, chrome: {chromedriverVersion: 106.0.5249.61 (511755355844..., userDataDir: C:\Users\MFURMA~1\AppData\L...}, goog:chromeOptions: {debuggerAddress: localhost:62076}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: WINDOWS, proxy: Proxy(), se:cdp: ws://localhost:62076/devtoo..., se:cdpVersion: 106.0.5249.119, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true}
Element: [[ChromeDriver: chrome on WINDOWS (ae9d19eb2960eab4ec35715c75dd7501)] -> xpath: //a[contains(text(),'Dalej')]]
Session ID: ae9d19eb2960eab4ec35715c75dd7501

    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:65)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.execute(NettyHttpHandler.java:49)
    at org.openqa.selenium.remote.http.AddSeleniumUserAgent.lambda$apply$0(AddSeleniumUserAgent.java:42)
    at org.openqa.selenium.remote.http.Filter.lambda$andFinally$1(Filter.java:56)
    at org.openqa.selenium.remote.http.netty.NettyClient.execute(NettyClient.java:99)
    at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:181)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.invokeExecute(DriverCommandExecutor.java:167)
    at org.openqa.selenium.remote.service.DriverCommandExecutor.execute(DriverCommandExecutor.java:142)
    at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:547)
    at org.openqa.selenium.remote.RemoteWebElement.execute(RemoteWebElement.java:257)
    at org.openqa.selenium.remote.RemoteWebElement.click(RemoteWebElement.java:78)
    at web.eshop.street.Test123.test(Test123.java:22)
    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.testng.internal.invokers.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:135)
    at org.testng.internal.invokers.TestInvoker.invokeMethod(TestInvoker.java:673)
    at org.testng.internal.invokers.TestInvoker.invokeTestMethod(TestInvoker.java:220)
    at org.testng.internal.invokers.MethodRunner.runInSequence(MethodRunner.java:50)
    at org.testng.internal.invokers.TestInvoker$MethodInvocationAgent.invoke(TestInvoker.java:945)
    at org.testng.internal.invokers.TestInvoker.invokeTestMethods(TestInvoker.java:193)
    at org.testng.internal.invokers.TestMethodWorker.invokeTestMethods(TestMethodWorker.java:146)
    at org.testng.internal.invokers.TestMethodWorker.run(TestMethodWorker.java:128)
    at java.base/java.util.ArrayList.forEach(ArrayList.java:1541)
    at org.testng.TestRunner.privateRun(TestRunner.java:808)
    at org.testng.TestRunner.run(TestRunner.java:603)
    at org.testng.SuiteRunner.runTest(SuiteRunner.java:429)
    at org.testng.SuiteRunner.runSequentially(SuiteRunner.java:423)
    at org.testng.SuiteRunner.privateRun(SuiteRunner.java:383)
    at org.testng.SuiteRunner.run(SuiteRunner.java:326)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:95)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1249)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
    at org.testng.TestNG.runSuites(TestNG.java:1092)
    at org.testng.TestNG.run(TestNG.java:1060)
    at com.intellij.rt.testng.IDEARemoteTestNG.run(IDEARemoteTestNG.java:66)
    at com.intellij.rt.testng.RemoteTestNGStarter.main(RemoteTestNGStarter.java:109)
Caused by: java.util.concurrent.TimeoutException
    at java.base/java.util.concurrent.CompletableFuture.timedGet(CompletableFuture.java:1886)
    at java.base/java.util.concurrent.CompletableFuture.get(CompletableFuture.java:2021)
    at org.asynchttpclient.netty.NettyResponseFuture.get(NettyResponseFuture.java:206)
    at org.openqa.selenium.remote.http.netty.NettyHttpHandler.makeCall(NettyHttpHandler.java:59)
    ... 40 more

===============================================
Default Suite
Total tests run: 1, Passes: 0, Failures: 1, Skips: 0
===============================================

Process finished with exit code 0

The first run is correct. Subsequent runs throw an error. Please help me.

JulienBreton commented 2 years ago

Hi @surli and @testermarcinf

Do you use the Java11+ HTTP Client ?

In my case with the Java11+ HTTP client I don't have the exception java.util.concurrent.TimeoutException anymore.

If you want to try : https://www.selenium.dev/blog/2022/using-java11-httpclient/

0xC4N1 commented 2 years ago

To reproduce this issue with the selenium/standalone-chrome image it might be important to mention that we observed this issue doesn't occur with SE_OPTS=--log-level FINEST. This issue seems to occur only without SE_OPTS or with SE_OPTS=--log-level FINE

HemanthRajaSudhakar commented 2 years ago

@JulienBreton As you told I am not getting java.util.concurrent.TimeoutException anymore when using Java11+http client instead of async http client. But getting this org.openqa.selenium.TimeoutException: java.net.http.HttpTimeoutException: request timed out Same exact scenes like how random java.util.concurrent.TimeoutException occurs, similarly now I am seeing this org.openqa.selenium.TimeoutException: java.net.http.HttpTimeoutException: request timed out exception.

This is the log I am seeing when testcase fails

org.openqa.selenium.TimeoutException: java.net.http.HttpTimeoutException: request timed out Build info: version: '4.5.0', revision: 'fe167b119a' System info: os.name: 'Linux', os.arch: 'amd64', os.version: '4.15.0-191-generic', java.version: '11.0.16' Driver info: org.openqa.selenium.remote.RemoteWebDriver Command: [49a6dd37daa37d56faede5b8868bc81c, setTimeout {implicit=0}] Capabilities {acceptInsecureCerts: true, browserName: chrome, browserVersion: 105.0.5195.52, chrome: {chromedriverVersion: 105.0.5195.19 (b9c217c128c1..., userDataDir: /tmp/.com.google.Chrome.5fYJvn}, goog:chromeOptions: {debuggerAddress: localhost:40025}, networkConnectionEnabled: false, pageLoadStrategy: normal, platformName: LINUX, proxy: Proxy(), se:cdp: ws://10.0.6.20:4444/session..., se:cdpVersion: 105.0.5195.52, se:vnc: ws://10.0.6.20:4444/session..., se:vncEnabled: true, se:vncLocalAddress: ws://10.0.6.20:7900, setWindowRect: true, strictFileInteractability: false, timeouts: {implicit: 0, pageLoad: 300000, script: 30000}, unhandledPromptBehavior: dismiss and notify, webauthn:extension:credBlob: true, webauthn:extension:largeBlob: true, webauthn:virtualAuthenticators: true} Session ID: 49a6dd37daa37d56faede5b8868bc81c at org.openqa.selenium.remote.http.jdk.JdkHttpClient.execute(JdkHttpClient.java:238) at org.openqa.selenium.remote.tracing.TracedHttpClient.execute(TracedHttpClient.java:55) at org.openqa.selenium.remote.HttpCommandExecutor.execute(HttpCommandExecutor.java:181) at org.openqa.selenium.remote.TracedCommandExecutor.execute(TracedCommandExecutor.java:51) at org.openqa.selenium.remote.RemoteWebDriver.execute(RemoteWebDriver.java:547) at org.openqa.selenium.remote.RemoteWebDriver$RemoteWebDriverOptions$RemoteTimeouts.implicitlyWait(RemoteWebDriver.java:858) 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.testng.internal.MethodInvocationHelper.invokeMethod(MethodInvocationHelper.java:104) at org.testng.internal.InvokeMethodRunnable.runOne(InvokeMethodRunnable.java:54) at org.testng.internal.InvokeMethodRunnable.run(InvokeMethodRunnable.java:44) at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829) Caused by: java.net.http.HttpTimeoutException: request timed out at java.net.http/jdk.internal.net.http.HttpClientImpl.send(HttpClientImpl.java:559) at java.net.http/jdk.internal.net.http.HttpClientFacade.send(HttpClientFacade.java:119) at org.openqa.selenium.remote.http.jdk.JdkHttpClient.execute(JdkHttpClient.java:236)

@diemol @titusfortner please throw some light on why this exception occurs Thanks!

diemol commented 2 years ago

@HemanthRajaSudhakar I would need a test to reproduce the issue. Seems the Java 11 HTTP client is working for most users, so we need to get a way to reproduce it with the new client.

JulienBreton commented 2 years ago

@HemanthRajaSudhakar I also have org.openqa.selenium.TimeoutException: java.net.http.HttpTimeoutException This bug has no end. Now we have to find a way to reproduce it.

testermarcinf commented 2 years ago

Hi @surli and @testermarcinf

Do you use the Java11+ HTTP Client ?

In my case with the Java11+ HTTP client I don't have the exception java.util.concurrent.TimeoutException anymore.

If you want to try : https://www.selenium.dev/blog/2022/using-java11-httpclient/

Hi. In my case it looks like it helped. Entry "System.setProperty (" webdriver.http.factory "," jdk-http-client ");" I had to put it directly in the testing method (where I have the @Test notation). Thank you very much.

efranken commented 2 years ago

I'd appreciate if someone could provide some clarification on the documentation provided at https://www.selenium.dev/blog/2022/using-java11-httpclient/

The documentation states that if you're using Selenium Grid, to download the client and set it with the --ext flag, but it only lists for standalone grid mode. If running in fully distributed mode (router, distributor, queue, map as separate components) which components need to be set?

If running the new client on the Grid, does the system property still need to be set and the pom for the tests updated?

Is there any definitive way to check if tests running on the grid are utilizing the java 11+ http client as opposed to the asynchttpclient?

titusfortner commented 2 years ago

@diemol do we need to add something to grid documentation for this?

diemol commented 2 years ago

I added a note to the blog post. In short, if you want to use the new HTTP client, it needs to be updated everywhere (tests on the client side, and each Grid component).

titusfortner commented 2 years ago

Do we have anything in our docs about it, though? Blog post is good for explaining *why, but should be a straightforward what in the docs?

tfactor2 commented 2 years ago

We faced a similar issue on Selenium 4.1.4 therefore, using the java11 HTTP client was not an option for us. The problem was fixed as soon we downgraded the image of selenium/chrome to selenium/standalone-chrome-debug:3.141.59.

PS: Upgrade of Selenium is not an option for us (and probably for others) as the latest version of stable Spring Boot (2.7.5) refers to Selenium 4.1.4, and we try to avoid the jar hell.

taylorpaul commented 2 years ago

I am a noob when it comes to selenium; figured I should start there.

I amusing selenium grid with the latest images for selenium/hub, selenium/node-chrome, selenium/node-edge, selenium/node-firefox and experiencing frequent Timeout Exceptions/behavior described above and want to try the new java11 HTTP client. From the blog post I see:

"If you are using the Hub/Node(s) mode or the Distributed mode, setting the -Dwebdriver.http.factory=jdk-http-client and —-ext flags needs to be done for all components."

But I am not sure from the documentation it is possible to set these options in the available python webdriver.FirefoxOptions()/ChromeOptions()/EdgeOptions() or how to do so.

Any pointers on how to check which HTTP client tests in grid are using (Seconding @efranken question) and how to set to the java11 HTTP client would be greatly appreciated!

therealdjryan commented 2 years ago

@taylorpaul, The latest docker-selenium images should have those values already set. I think you only need to do two things