The problem is that your work computer is always looking for your company's proxy server, and this happens whether or not you are at work, or using a hotspot, or even at home.
The easiest way to overcome this is to add a parameter atWork
to your function and then use the httr::use_proxy()
function to set the appropriate proxy to use:
myFunction <- function(arg1, atWork)
if(atWork){
proxy.string <- use_proxy("http://proxy-server.YourCompanyName.com", port = 8080)
} else {
proxy.string <- use_proxy("")
}
# then open a session
sess <- html_session(myUrl, proxy.string)
do stuff here
return(result)
}
of course, you will need to replace proxy-server.YourCompanyName
with your actual company's proxy server url.