How to increase Selenium grid session timeout?
Asked Answered
P

2

13

While running my test, I need to have long delays (~40 seconds).

And I see, that Selenium session gets deleted during that time.

Please help: How can I configure session timeout to increase?

Here what I see in less, that 30 secs, after delay started in the Selenium node log:

INFO org.openqa.selenium.remote.server.DriverServlet - Session 7f5fffec-4882-4c4c-b091-c780c66d379d deleted due to client timeout

And after 40 seconds sleep, I'm getting this exception in my code:

org.openqa.selenium.remote.SessionNotFoundException

I tried to increase all possible timeouts. Here is how I start hub:

java -jar selenium-server-standalone.jar -role hub 
-hubConfig selenium_hub.json 
-nodeTimeout 61 
-remoteControlPollingIntervalInSeconds 180 
-sessionMaxIdleTimeInSeconds 240 
-newSessionMaxWaitTimeInSeconds 250 
-timeout 59

And here is selenium_hub.json:

{
  "host": null,
  "port": 4444,
  "newSessionWaitTimeout": -1,
  "servlets": [],
  "prioritizer":  null,
  "capabilityMatcher": "org.openqa.grid.internal.utils.DefaultCapabilityMatcher",
  "throwOnCapabilityNotPresent": true,
  "nodePolling": 5000,
  "cleanUpCycle": 5000,
  "timeout": 60000,
  "browserTimeout": 60000,
  "maxSession": 5,
  "jettyMaxThreads": -1
}

No any timeouts configured on the nodes. Here is what I see in my Grid console:

browserTimeout : 60000
capabilityMatcher : org.openqa.grid.internal.utils.DefaultCapabilityMatcher
cleanUpCycle : 5000
host : null
hubConfig : /usr/local/selenium/config/selenium_hub.json
jettyMaxThreads : -1
maxSession : 5
newSessionMaxWaitTimeInSeconds : 250
newSessionWaitTimeout : -1
nodePolling : 5000
nodeTimeout : 61
port : 4444
prioritizer : null
remoteControlPollingIntervalInSeconds : 180
role : hub
servlets : []
sessionMaxIdleTimeInSeconds : 240
throwOnCapabilityNotPresent : true
timeout : 59000

I'm using Selenium 2.45

Purposive answered 26/3, 2015 at 7:30 Comment(2)
Hi, can I ask you how did you find all these parameters? I can't see many of them mentioned in the documentation. Thanks!Enthuse
Good question. I do not think it's well documented. I just used default files from Selenium: github.com/SeleniumHQ/selenium/tree/master/java/server/src/org/…Purposive
P
8

I finally figured it out!

Solution is actually very easy: nodes needs to be restarted after configuration changed on the hub.

It is not really obvious:

When I changed configuration on the hub, then I restarted it. Node would re-register with the hub automatically. Then looking at the console, I can see new configuration parameters taking effect. Even more, as I'm looking at the node configurations, I see same parameters changed on the nodes. That's misleading! Because even though nodes re-registered, but their configuration has NOT been changed. It only changes, when node is restarted, too. I think, this is Selenium bug - node should re-configure during re-registration.

Purposive answered 26/3, 2015 at 17:17 Comment(3)
@ Slavik, I used to restart my node every day even if there is no changes in Hub. Even so am getting this deleted due to client time out. How to Proceed.Pich
I would recommend you ask that question in separate thread. I can think of increasing timeouts. Another solution would be to send KeepAlive events.Purposive
@madhu take a look at github.com/seleniumhq/selenium/issues/1106Isocyanide
K
-2
C#

driver = new RemoteWebDriver(new Uri("http://host:4444/wd/hub"), capabilities);
driver.Manage().Timeouts().ImplicitlyWait(TimeSpan.FromSeconds( desired_time ));

P.S. I'm using Selenium grid 2.53 and firefox 46.0

Kistler answered 24/1, 2017 at 11:50 Comment(1)
Your answer concerns one of driver timeouts rather than Selenium Grid timeout.Jael

© 2022 - 2024 — McMap. All rights reserved.