1

I am using AWS EC2 instances to create a Selenium Grid. I have one instance acting as the Hub and other instances acting as nodes.

Once I terminate the nodes, they still remain in the grid for quite sometime (like 15-20 minutes) before being completely removed, therefore, the API is returning incorrect values:

GRID

For example, the API is returning:

"slotCounts": {
    "free": 9,
    "total": 10
  },

But really, there are ONLY 4 slots total, because the other nodes are no longer connected. Is there a configuration setting that will remove the nodes from grid faster after there is no longer a connection?

I start the Hub like this:

java -jar selenium-server-standalone-3.141.59.jar -role hub -port 4444;

And the clients like this:

java -jar -Dwebdriver.chrome.driver=chromedriver selenium-server-standalone-3.141.59.jar -role node -hub http://10.0.1.119:4444/grid/register -browser browserName=chrome,maxInstances=2,version=latest,seleniumProtocol=WebDriver

The nodes do eventually disappear from the grid but only after they have been quit (by quit, I mean after the computer that runs the node has been shutdown) for quite awhile (maybe 10-20 mins).

I looked at this Stack Overflow question: SO

And I can't figure out if I need to set nodePolling, timeout, browsertimout or a combination of them?

Update: I just tested it again, and after the computer that runs the nodes was shutdown, it took around 20-22 mins for the grid to reflect that in the API.

mcool
  • 457
  • 4
  • 29

1 Answers1

-1

As per the Selenium Grid helptext:

-timeout, -sessionTimeout
  <Integer> in seconds : Specifies the timeout before the server
  automatically kills a session that hasn't had any activity in the last X
  seconds. The test slot will then be released for another test to use.
  This is typically used to take care of client crashes. For grid hub/node
  roles, cleanUpCycle must also be set. If a node does not specify it, the
  hub value will be used.
  

So once the nodes are terminated to remove them completely from the console you can configure either of the following parameters:

  • -timeout

    java -jar -Dwebdriver.chrome.driver=chromedriver selenium-server-standalone-3.141.59.jar -role node -hub http://192.168.225.173:4444/grid/register -browser browserName=chrome,maxInstances=2 -timeout 2
    
  • -sessionTimeout:

    java -jar -Dwebdriver.chrome.driver=chromedriver selenium-server-standalone-3.141.59.jar -role node -hub http://192.168.225.173:4444/grid/register -browser browserName=chrome,maxInstances=2 -sessionTimeout 3
    
  • cleanUpCycle:

    java -jar -Dwebdriver.chrome.driver=chromedriver selenium-server-standalone-3.141.59.jar -role node -hub http://192.168.225.173:4444/grid/register -browser browserName=chrome,maxInstances=2 -cleanUpCycle 4
    

References

You can find a couple of relevant detailed discussions in:

undetected Selenium
  • 183,867
  • 41
  • 278
  • 352
  • So using ANY 1 out of those params (timeout, sessionTimeout, cleanUpCycle) will accomplish what I need? I re-read the documentation so many times and couldn’t make sense of my exact need. I thought the param I need to set would be on the hub though, not the nodes? – mcool Apr 11 '22 at 18:46
  • @mcool Even that would be a better approach as the help text explicitly specifies _`...If a node does not specify it, the hub value will be used....`_ – undetected Selenium Apr 11 '22 at 18:49
  • Okay I will try it out on the nodes first when I get back to my computer – mcool Apr 11 '22 at 19:08
  • So I tried as you suggested with setting the `timeout` param to `2` for the node and it did not do as expected. I thought that this would remove the node from the console after `2` seconds. I terminated the instance, and as of right now it has been `7` mins and it is still in the console. – mcool Apr 11 '22 at 19:41
  • @mcool Observe the HUB logs. The browser state (cookies) needs additional time to expire. – undetected Selenium Apr 11 '22 at 19:43
  • And how do I fix it so that the node gets removed from console immediately? That's what my original question was – mcool Apr 11 '22 at 19:46
  • Check the reference discussion – undetected Selenium Apr 11 '22 at 19:47
  • 2
    The link you put at the bottom of your answer? That also does not help, that is just reiterating what you have already said that did not work – mcool Apr 11 '22 at 19:54