RSelenium icon indicating copy to clipboard operation
RSelenium copied to clipboard

Can not connect to the Selenium running in Docker on remote server

Open rcepka opened this issue 2 years ago • 2 comments

I am struggled for several days, trying to get connected to the Selenium server running on remote docker machine (not my localhost).

I have installed Docker on Ubuntu 20.04. Running firefox -v return Mozilla Firefox 117.0.1.

I did from my server console: docker run -dt -p 4445:4444 selenium/standalone-firefox:117.0 and I see the Selenium nicely running on "http://my-server-ip:4445/ui"

Finally I am trying to connect to Selenium from R. In my Rstudio I run the code:

library(RSelenium)

 remDr <- RSelenium::remoteDriver(
   remoteServerAddr = "my-remote-server-ip",
   port = 4445L,
   browser = "firefox",
   )

 remDr$open()
#> [1] "Connecting to remote server"
#> $id
#> [1] NA

Created on 2023-09-16 with reprex v2.0.2

Computer is just hanging for several minutes and can not connect to the Selenium server. I tried this also with Selenium Chrome server but with no luck. What am I doing wrong please? Many thanks in advance...

rcepka avatar Sep 16 '23 12:09 rcepka

Same issue on my side. Not able to go via docker. using windows 10 machine. have sought help on stackoverflow: https://stackoverflow.com/questions/77498684/rselenuim-docker-unable-to-connect-to-remote-server-for-firefox

 system("docker run -d -p 4449:4444 selenium/standalone-firefox")

library(RSelenium)

remDr <- remoteDriver(remoteServerAddr = "localhost", 
                      port = 4445L, 
                      browserName = "firefox"
                      )
remDr$open(silent = FALSE)
[1] "Connecting to remote server"
Error in checkError(res) : 
  Undefined error in httr call. httr output: Failed to connect to localhost port 4445 after 2252 ms: Couldn't connect to server

sessioninfo()


sessionInfo()
R version 4.3.2 (2023-10-31 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19045)

Matrix products: default


locale:
[1] LC_COLLATE=English_Australia.utf8  LC_CTYPE=English_Australia.utf8   
[3] LC_MONETARY=English_Australia.utf8 LC_NUMERIC=C                      
[5] LC_TIME=English_Australia.utf8    

time zone: Australia/Sydney
tzcode source: internal

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] RSelenium_1.7.9

loaded via a namespace (and not attached):
 [1] wdman_0.2.6      assertthat_0.2.1 R6_2.5.1         rappdirs_0.3.3   netstat_0.1.2   
 [6] ps_1.7.5         bitops_1.0-7     xml2_1.3.5       processx_3.8.2   caTools_1.18.2  
[11] binman_0.1.3     compiler_4.3.2   httr_1.4.7       rstudioapi_0.14  tools_4.3.2     
[16] curl_5.1.0       Rcpp_1.0.11      yaml_2.3.7       jsonlite_1.8.7   semver_0.2.0    

Any help to resolve issue is much appreciated.

JoeFernando avatar Nov 17 '23 02:11 JoeFernando

RSelenium does not work with the latest version of Selenium (see #280). Either:

  1. Use an older version of Selenium (e.g. docker run -d -p 4444:4444 -p 7900:7900 --shm-size="2g" selenium/standalone-firefox:4.8.3). You might have to experiment to find a version that RSelenium is compatible with.
  2. Use the newer selenium package, that works with the latest version of Selenium.

ashbythorpe avatar Dec 05 '23 18:12 ashbythorpe