Hi. I didn't solve this problem, but I find another alternative in which I can use Rselenium properly: I used shell() function in order to close the server and port.
Dr = RSelenium::rsDriver(browser = 'firefox', port = 4444L)
Driver = Dr[['client']]
Driver$close()
kill = 'for /f "tokens=5" %a in (\'netstat -aon ^| find ":4444" ^| find "LISTENING"\') do taskkill /f /pid %a'
shell(kill, ignore.stderr = TRUE, ignore.stdout = TRUE)
Another thing you could try is using a port value other than 4444L (there's a massive range of ports available, see the IANA recommended ones in the netstat package source code here), for example, any of the ~500 integers between 14415 and 14935 are usually free.
I'll try to fix the issue with netstat::free_port(). Do you remember which operating system you were using at the time of the error?
Thanks very much. sessionInfo() provides the R version, operating system name, locale (i.e. OS language, time, currency unit), and loaded R packages. It is recommendedhere for helping reproduce bugs, so nothing to worry about regarding security.