Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

access plotly behind proxy

Tags:

r

proxy

plotly

I'm trying to make an interactive version of my ggplot2 using the plotly package. It works fine when I do it from a personal computer. Unfortunately, I'm at work, on a windows machine behind a proxy, and it fails to connect to the plotly server. Browsing the code source, I think the issue might be with the postFrom function from RCurl. I tried adding the proxy to options(RCurlOptions = list(proxy="http://proxyurl:8080")), but that doesn't seem to improve things. Is there a known workaround?

library(httr)
set_config(use_proxy(url="http://proxy.xxx.fr",port=8080,username="",password=""))
options('RCurlOptions'= c(options('RCurlOptions'), list(proxy = 'http://proxy.xxxx.fr:8080')))
library(plotly)
set_credentials_file(username="baptiste", api_key="xxxx")

require(plotly)

p2 <- qplot(1,1)
py <- plotly(username="baptiste")
out <- py$ggplotly(p2)
# Error in function (type, msg, asError = TRUE)  : couldn't connect to host
like image 426
baptiste Avatar asked Jul 15 '14 11:07

baptiste


2 Answers

pub$makecall in plotly.R overwrites your global RCurlOptions. I've submitted a pull request to fix this.

like image 142
Matthew Plourde Avatar answered Oct 20 '22 08:10

Matthew Plourde


I think that if you set your RCurl options like this:

opts <- list(
  proxy         = "myweb.proxy.com", 
  proxyusername = "myproxyuser", 
  proxypassword = "myproxypassword", 
  proxyport     = 8080
)

options(RCurlOptions = opts)

Then you should be able to connect to the host, at least this works for me behind my work proxy.

like image 45
rjad Avatar answered Oct 20 '22 08:10

rjad