I am currently running Chrome tests using Selenium Grid and am using the default 4444 and 5555 ports to comunicate between the hub and nodes. Everything is running fine but I do see that on the selenium nodes multiple chromedrivers are started and each listens on a seemingly random (albeit available) port number.
I see this using the command
netstat -tulpn | grep chromedriver
which returns for example
tcp 0 0 127.0.0.1:18955 0.0.0.0:* LISTEN 51665/chromedriver
tcp 0 0 127.0.0.1:17932 0.0.0.0:* LISTEN 51365/chromedriver
tcp 0 0 127.0.0.1:34668 0.0.0.0:* LISTEN 51206/chromedriver
tcp 0 0 127.0.0.1:43629 0.0.0.0:* LISTEN 51219/chromedriver
tcp 0 0 127.0.0.1:5645 0.0.0.0:* LISTEN 10353/chromedriver
tcp 0 0 127.0.0.1:48782 0.0.0.0:* LISTEN 51221/chromedriver
tcp 0 0 127.0.0.1:26258 0.0.0.0:* LISTEN 51271/chromedriver
tcp 0 0 127.0.0.1:19699 0.0.0.0:* LISTEN 51308/chromedriver
tcp 0 0 127.0.0.1:36787 0.0.0.0:* LISTEN 51207/chromedriver
tcp 0 0 127.0.0.1:28180 0.0.0.0:* LISTEN 51663/chromedriver
tcp 0 0 127.0.0.1:29076 0.0.0.0:* LISTEN 51295/chromedriver
Normally this is ok, but occasionally they use a port in the 9500->9599 range which is used by Xvnc, causing errors when starting and stopping vncservers.
Is there a way to force chromedriver to use or avoid a specific range of ports? Existing answers using ChromeDriverService seem only to address the chromedriver port issue when running locally, and set the port to a single specific value.