Error in checkError(res) : Undefined error in httr call. httr output: Failed to connect to localhost port 4445: Connection refused
Asked Answered
T

1

7

I try to open a remote driver with RSelenium but I keep on facing the same issue with Docker.

Within Docker I run

$ docker run -d -p 4445:4444 selenium/standalone-firefox:2.53.0

then

$ docker ps

Docker returns

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a89435c68373 selenium/standalone-firefox:2.53.0 "/opt/bin/entry_poin…" About an hour ago Up About an hour 0.0.0.0:4445->4444/tcp determined_sammet

then in R

remDr <- remoteDriver(port = 4445L)
remDr$open()

and I receive this error

Error in checkError(res) : 
  Undefined error in httr call. httr output: Failed to connect to localhost port 4445: Connection refused

I can't figure out how to handle this. Can anyone help? Thanks


Thanks to Ralf Stubner the command

 remDr <- remoteDriver(remoteServerAddr = "yourIP", port = 4445L) 

has fixed my issue

Tobolsk answered 18/10, 2018 at 18:51 Comment(9)
What is the output of the mentioned docker ps command?Docila
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a89435c68373 selenium/standalone-firefox:2.53.0 "/opt/bin/entry_poin…" About an hour ago Up About an hour 0.0.0.0:4445->4444/tcp determined_sammetTobolsk
Thanks. Please edit your question to include this additional information. It is really hard to read in a comment.Docila
Done Ralf. Thanks for your timeTobolsk
What you describe works for me on Linux. Which OS are you using?Docila
I use Windows10Tobolsk
In that case have a look at the RSelenium::docker vignette, section "RSelenium and Running Containers". On windows you might have to specify an IP address in addition to the port.Docila
Thanks Ralf ! remDr <- remoteDriver(remoteServerAddr = "myIP", port = 4445L) seems to fix my issue!Tobolsk
Great. Instead of editing your question you could post this as an answer including how to obtain the IP address.Docila
T
5

I've found putting a sleep in between seems to help avoid this error:

system("sudo docker pull selenium/standalone-chrome",wait=T)
Sys.sleep(5)
system("sudo docker run -d -p 4445:4444 selenium/standalone-chrome",wait=T)
Sys.sleep(5)
remDr <- remoteDriver(port=4445L, browserName="chrome")
Sys.sleep(15)
remDr$open()
Tangible answered 29/10, 2019 at 16:39 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.