1

I am facing an issue while running the rsDriver() function to open up the chrome browser.

Code:

library("RSelenium")
library("wdman")
mybrowser <- rsDriver(browser=c("chrome"), chromever="80.0.3987.16",port = 443L)
remDr <- mybrowser$client
remDr$navigate("https://google.co.in/")
Sys.sleep(2)

When I run this code on my machine while connected to my home network the code works as expected. But when I run this code from my office network, the rsDriver(browser=c("chrome"), chromever="80.0.3987.16",port = 443L) gives me the below error and I am stuck at this point.

checking Selenium Server versions:
BEGIN: PREDOWNLOAD
Error in open.connection(con, "rb") : 
Timeout was reached: [www.googleapis.com] Operation timed out after 10000 milliseconds with 0 out of
0 bytes received

I tried connecting through the company's proxy with the below code but still no luck. I tried using the port numbers 4444,4445,4567 but still the same error.

cprof <- list(chromeOptions = list(args = list("--proxy-server= gproxy.go.company.org:8080")))
mybrowser <- rsDriver(browser=c("chrome"), chromever="80.0.3987.16", port = 443L,extraCapabilities = cprof)

It would be very helpful someone can help me in understanding the issue and suggest me a solution. Am I missing something in the code. Any help would be highly appreciated. Also do let me know for any additional information required.

zx8754
  • 52,746
  • 12
  • 114
  • 209
Anish
  • 19
  • 5

2 Answers2

0

To me this looks like a proxy issue. Are you able to retrieve an arbitrary website? E.g. using httr::GET("www.google.com"). If not, this would also point to a problem with the proxy.

Have you tried to configure it in .Renviron? Like so:

file.edit('~/.Renviron')

Add this line to the file and restart RStudio:

http_proxy=USER:PASSWORD@PROXY:PORT

Another option: setting proxy with httr/curl:

set_config(use_proxy(url="proxy.com",
                 port = 8080,
                 username = "foo",
                 password = "bar"))
HeiN3r
  • 178
  • 5
  • Hi @HeiN3r Thank you for your assistance. I tried httr::GET("www.google.com") but I receive the following error: Error in curl::curl_fetch_memory(url, handle = handle) : Timeout was reached: [www.ggogle.co.in] Operation timed out after 10000 milliseconds with 0 out of 0 bytes received Also I tried adding the line http_proxy=USER:PASSWORD@PROXY:PORT to the Renviron file and restarted the RStudio, but still no luck. I have used http_proxy = "Domain\\username":"Pwd#NNNN"@"gproxy.go.company.org":8080 – Anish Mar 13 '20 at 12:04
  • Strange ... did you actually use the quotation marks in .Renv or just here in the comments? If yes, you should remove them. In addition, I added another way to specifiy the proxy using `httr`. Does this work? However, this will help you with `GET()` but probably not with your original problem. But at least you know, that it actually is the proxy and you "only" need to figure out the correct .Renv specification. – HeiN3r Mar 13 '20 at 12:29
  • The second method helped me with GET(). I am now able to execute the httr::GET("www.google.com") command and it returns me some output. But still the rsDriver() is showing the same error as stated in the description. I now understand that there is some issue with the proxy. But it will be very very helpful of you if you guide me – Anish Mar 13 '20 at 12:40
  • Ok, so you confirmend now that with a correct specification of the proxy you are able to connect to outside servers. I would suggest to play around with the .Renviron file. If you get this to work correctly (maybe tested with `GET()` to exclude other problems), I hope/assume that this will also help with rsDriver(). – HeiN3r Mar 13 '20 at 12:43
  • I also found this: https://stackoverflow.com/questions/50388282/rselenium-behind-proxy. That looks like a solution to me. – HeiN3r Mar 13 '20 at 13:08
  • I saw the exact same solution before this post, but for some reason it is not working for me. I am following the exact same steps as mentioned. – Anish Mar 13 '20 at 14:13
  • Ok, I am afraid I am out of ideas at this point. However, I still assume that a working .Renv would help you with Selenium. – HeiN3r Mar 16 '20 at 08:26
0

Achieved this by switching the networks, first connected to my local network and when the browser opens up switch to company's network.

Anish
  • 19
  • 5