R error in connection to host - r

I have installed R 3.0.2 and package KEGGREST. While using it's command, I get the following error
Error in function (type, msg, asError = TRUE) : couldn't connect to
host
I can very well install package from internet after using --internet2 option, which uses proxy details from Internet explorer.
Please help.
Thanks in advance

httr uses a different method to connect to the internet: you need to explicitly set the proxy using the following command:
set_config(use_proxy(url='your.proxy.url',port,username,password))
See
http://www.inside-r.org/packages/cran/httr/docs/use_proxy
Solution. How to install_github when there is a proxy
For more details

Related

R: download data securely using TLS/SSL

Official Statements
In the past the base R download.file() was unable to work with HTTPS protocols and it was necessary to use RCurl. Since R 3.3.0:
All builds have support for https: URLs in the default methods for download.file(), url() and code making use of them. Unfortunately that cannot guarantee that any particular https: URL can be accessed. ... Different access methods may allow different protocols or use private certificate bundles ...
The download.file() help still says:
Contributed package 'RCurl' provides more comprehensive facilities to download from URLs.
which (by the way includes cookies and headers management).
Based on RCurl FAQ (look for "When I try to interact with a URL via https, I get an error"), HTTPS URLs can be managed with:
getURL(url, cainfo="CA bundle")
where CA bundle is the path to a certificate authority bundle file. One such a bundle is available from the curl site itself:
https://curl.haxx.se/ca/cacert.pem
Current status
Tests are based on Windows platforms
For many HTTPS websites download.file() works as stated:
download.file(url="https://www.google.com", destfile="google.html")
download.file(url="https://curl.haxx.se/ca/cacert.pem", destfile="cacert.pem")
As regards RCurl, using the cacert.pem bundle, downloaded above, one might get an error:
library(RCurl)
getURL("https://www.google.com", cainfo = "cacert.pem")
# Error in function (type, msg, asError = TRUE) :
# SSL certificate problem: unable to get local issuer certificate
In this instance, simply removing the reference to the certificate bundle solves the problem:
getURL("https://www.google.com") # works
getURL("https://www.google.com", ssl.verifypeer=TRUE) # works
ssl.verifypeer = TRUE is used to be sure that success is not due to getURL() suppressing security. The argument is documented in RCurl FAQ.
However, in other instances, the connection fails:
getURL("https://curl.haxx.se/ca/cacert.pem")
# Error in function (type, msg, asError = TRUE) :
# error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
And similarly, using the previously downloaded bundle:
getURL("https://curl.haxx.se/ca/cacert.pem", cainfo = "cacert.pem")
# Error in function (type, msg, asError = TRUE) :
# error:1407742E:SSL routines:SSL23_GET_SERVER_HELLO:tlsv1 alert protocol version
The same error happens even when suppressing the security:
getURL("https://curl.haxx.se/ca/cacert.pem", ssl.verifypeer=FALSE)
# same error as above
Questions
How to use HTTPS properly in RCurl?
As regards mere file downloads (no headers, cookies, etc.), is there any benefit in using RCurl instead of download.file()?
Is RCurl become obsolete and should we opt for curl?
Update
The issue persists as of
R version 3.4.1 (2017-06-30) under Windows 10.
openssl bundled with RCurl is a bit old currently, which does not support the TLS v1.2
Yes, curl package is OK
Or you can use httr package which is a wrapper for the curl package
> library("httr")
> GET("https://curl.haxx.se/ca/cacert.pem",config(sslversion=6,ssl_verifypeer=1))
Response [https://curl.haxx.se/ca/cacert.pem]
Date: 2017-08-16 17:07
Status: 200
Content-Type: application/x-pem-file
Size: 256 kB
<BINARY BODY>

R : Couldn't resolve host name

I try to install rword2vec :
library(devtools)
install_github("mukul13/rword2vec")
But I get this error message :
Error in curl::curl_fetch_disk(url, x$path, handle = handle) :
Couldn't resolve host name
Can you help me please to resolve this problem ?
Thank you
I ran into this same issue with other packages/libraries from GitHub while on a work network. I resolved the issue by switching to another internet network (e.g., my home internet). I was able to download the packages and install the packages.

How to install "factoextra" in R?

I am using R version 3.0.3. while running
library(devtools)
install_github("kassambara/factoextra")
Iam getting below error:
Downloading github repo kassambara/factoextra#master
Error in function (type, msg, asError = TRUE) :
Failed to connect to api.github.com port 443: Timed out
Can anyone please tell me how to install this package?
My guess would be that you are behind a proxy that blocks https or something like that. Just retry from another location and see if that fixes the issue. Or talk to your local system administrator and fix the issue.
It could also be a temporary github problem, in which case retrying at a later moment will fix the issue.

R - error installing package - Error in curl::curl_fetch_memory(url, handle = handle) : Couldn't connect to server

I am trying to install the BTYplus package in R.
devtools::install_github("mplatzer/BTYDplus", dependencies=TRUE)
library(BTYDplus)
demo(package="BTYDplus")
But it gives me the following error:
Downloading github repo mplatzer/BTYDplus#master
Error in curl::curl_fetch_memory(url, handle = handle) :
Couldn't connect to server
Did anyone had a similar issue when installing packages on R?
You can download the library externally and then import it to R:
Download from: https://github.com/mplatzer/BTYDplus
import from: Tools > Install Packages/ Package Archive File(.zip; .tar.gz)
Setting the proxy did work for me. Here is how I have done that:
library(httr)
set_config(use_proxy(url='http://my.proxy', port, username, password))
(and fill in your own url, port, username and password. Username and password were not necessary for me)
For me it was not proxy problem, instead the following lines solved my problem:
library(httr)
set_config(config(ssl_verifypeer = 0L))
Found it here.

oauth Handshake error using twitteR in R

I have been trying to download some tweets from using the tweeteR package in R
The code for my oauth credentials is
cred<-AuthFactory$new(consumerKey=consumerKey,
consumerSecret=consumerSecret,requestURL=reqURL,accessURL=accessURL,authURL=authURL)
When i try to run the following for handshake
cred$handshake(cainfo=system.file("CurlSSL","cacert.pem",package="RCurl"))
I am getting this error
Error in function (type, msg, asError = TRUE) :
Could not resolve host: api.twitter.com; No data record of requested type
I am running the code in a windows machine. (I have included the code for downloading cacert.pem)
I worked out the solution for this, for people who are behind a proxy they have to set the proxy options in RCurl too(setting the proxy for the R is not enough). This command works
options( RCurlOptions = list(verbose = TRUE,proxy = "host:port"))

Resources