How to increase Selenium grid session timeout?

Slavik picture Slavik · Mar 26, 2015 · Viewed 18.5k times · Source

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

Answer

Slavik picture Slavik · Mar 26, 2015

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.