How can I get past this 'SSL connect error' when using jsonlite::fromJSON in R? - r

Issue
I get the following error whenever I run
all_companies <- jsonlite::fromJSON("https://www.sec.gov/files/company_tickers_exchange.json")
Warning: URL 'https://www.sec.gov/files/company_tickers_exchange.json': status was 'SSL connect error'Error in open.connection(con, "rb") :
cannot open the connection to 'https://www.sec.gov/files/company_tickers_exchange.json'
Thank you in advance for any help!
What I've tried
I am trying to run this on a new work computer, it runs fine on my old work computer but the new one gives me this error.
It seems the difference causing this issue is that I am using {jsonlite} 1.8.2 on my new computer and 1.8.0 on my old computer. Deep in the definition of the fromJSON() function, the working version seems to use curl::curl() to establish a connection whereas the not-working version uses base::url().
The following example line from the help documentation runs fine on the new computer with version 1.8.2
data1 <- fromJSON("https://api.github.com/users/hadley/orgs")
I can access the JSON file I am trying to read on an internet browser.
I do not have permission to install Rtools on my computer to be able to compile an older version of {jsonlite}.

Related

Mlflow not running on machine

Please I am trying to run mlflow code in R after having installed it. However, after loading the library with library(mlflow) and I run mlflow_log_params("foo",42) I get the error message below printed in my console:
Error in rethrow_call(c_processx_exec, command, c(command, args), pty, :
Command 'C:/Users/IFEANYI/AppData/Local/r-miniconda/envs/r-mlflow-1.19.0/mlflow' not found #win/processx.c:982 (processx_exec)
I also get the same error message when I run mlflow_ui(). Please was there something I ought to have done during installation failure of which is affecting its functionality? Do I need to install and load the processx library in order for mlflow to run on my Windows10 machine? I really hope I can get advice to help me because I want to use mlflow in my machine learning projects. Thanks in advance of your generous help.
The error should disappear when setting MLFLOW_BIN system variable (Windows) to mlflow cli executable : "....conda\envs\r-mlflow-1.24.0\Scripts\mlflow.exe".
If it works please mark the problem as resolved.
Unfortunately, you will get next error "Error in wait_for(function() mlflow_rest("experiments", "list", client = client)" for which I cannot find the solution

Getting: "Failed to fetch metadata" when starting up Jupyter

I am using JupyterLab as my IDE and I have a couple of packages installed. Namely, the 'jupyterlab-dash' and 'juptyerlab-plotly' packages. My issue is when I go to launch 'juptyer lab' from terminal, I notice the following error:
Failed to fetch package metadata for 'jupyterlab-dash': URLError(gaierror(8, 'nodename nor servname provided, or not known'))
I'm not sure why this error is popping up but I've noticed this error only pops up when I have no internet connection (working on a train etc.). Could it be because these packages are trying to call something as I launch and because I don't have an internet connection it raises the error?
In the end I am able to use JupyterLab and the packages as intended (at-least it seems), but I'm curious why this error to 'fetch metadata' appears?
Thanks,

R RSelenium rsDriver chrome browser error on Mac

I am using a Mac (OS 10.13.6) and am trying to learn how to use RSelenium.
I have installed RSelenium but am having trouble with the rsDriver command:
rD <- rsDriver(browser="chrome",chromever="80.0.3987.106")
I get this error:
Could not open chrome browser.
Client error message:
Undefined error in httr call. httr output: Failed to connect to localhost port 4567: Connection refused
Check server log for further details.
Warning message:
In rsDriver(browser = "chrome", chromever = "80.0.3987.106") :
Could not determine server status.
I've been poking around for help for a couple of days now but am not clear on the appropriate solution here. I've tried the command with chromever="latest" and following the suggested workaround found here: stackoverflow.com/questions/55201226/. Furthermore, I don't know where to find the "server log" mentioned in the error.
Having never used this package before, or done this type of thing, I can't tell if I just don't have things set up on my machine correctly (non-R requirements of RSelenium that I need to install and where), or whether this is strictly a chrome browser setting/verison issue, or generally mac compatibility issue.
Does anyone an updated (i.e. not involving the defunct checkForServer() command) set of steps (for absolute Selenium beginners) for getting RSelenium set up and rsDriver working on a mac?
After a lot of trials and errors, I managed to solve the same issue by installing
Java SE Development Kit 14 on my Mac.
I hope this solves your issue.

Installing a package from private GitLab server on Windows

I am struggling with installing a package from a GitLab repository on a Windows computer.
I found different hints but still have problems to install my package from GitLab. First of all, I generated a public and private key with puttygen.exe. The files need to be changed afterwards, I had to remove comments and stuff so they look like my the file on my Unix system. So now, both public and private key files have just a single line.
I tried to install my package via devtools::install_git which takes very long and I get the error message
Error: Failed to install 'unknown package' from Git:
Error in 'git2r_remote_ls': Failed to authenticate SSH session: Unable to send userauth-publickey request
And with devtools::install_gitlab I get a different error message and I somehow have the feeling, the link which gets generated doesn't fit to my GitLab server.
Error: Failed to install 'unknown package' from GitLab:
cannot open URL 'https://gitlab.rlp.net/api/v4/projects/madejung%2FMQqueue.git/repository/files/DESCRIPTION/raw?ref=master'
My complete code to test at the moment is
creds <- git2r::cred_ssh_key(publickey="~/.ssh/id_rsa_gitlab.pub",
privatekey="~/.ssh/id_rsa_gitlab")
devtools::install_git(
url='git#gitlab.rlp.net:madejung/MQqueue.git',
quiet=FALSE,
credentials=creds)
devtools::install_gitlab(
repo='madejung/MQqueue.git',
host='gitlab.rlp.net',
quiet=FALSE,
credentials=creds
)
My id_rsa_gitlab.pub file looks like this and is just a single line:
ssh-rsa AAAA....fiwbw== rsa-key-20200121
The id_rsa_gitlab file has just the code:
AAABA.....3WNSIAGE=
Update
On my Mac system it works as expected after installing the libssh2 library via homebrew and and recompiling git2r with install.packages("git2r", type = "source").
So the working code on my machine is:
creds <- git2r::cred_ssh_key(publickey="~/.ssh/id_rsa_gitlab.rlp.net.pub",
privatekey="~/.ssh/id_rsa_gitlab.rlp.net")
devtools::install_git(
url='git#gitlab.rlp.net:madejung/MQqueue.git',
quiet=FALSE,
credentials=creds
)
For some strange reason, the devtools::install_git call needs about a minute to fail in the end. I have no idea where the problem here is.
After struggling for almost a day, I found a solution I can live with...
I first created a PAT (Personal Access Token) in my gitlab account and granted full API access. For some reason the read_only access didn't worked and I am now tired to figure out what the problem is.
After this I had still problems to install my package and for some reason, the wininet setting for downloading doesn't work.
I used the command capabilities("libcurl") to check if libcurl is available on my windows, which was and tried to overwrite wininet to libcurl by using method='libcurl' in the install function. Somehow, this was not enough so I overwrote the options variable download.file.method directly.
options("download.file.method"='libcurl')
devtools::install_gitlab(
repo='madejung/MQqueue',
auth_token='Ho...SOMETHING...xugzb',
host='gitlab.rlp.net',
quiet=FALSE, force=TRUE
)

install.keras() in RStudio fails with http connection error

I've been trying to install and run keras in RStudio (Windows) in vain.
i installed keras package using normal package "keras"
(didn't use github)
I've installed latest python (3.6) and Anaconda.
then i use
> library(keras)
> install.keras()
and i get this error:
Creating r-tensorflow conda environment for TensorFlow installation...
Fetching package metadata ... CondaHTTPError: HTTP 000 CONNECTION
FAILED for url
https://repo.continuum.io/pkgs/main/win-64/repodata.json.bz2
Elapsed: -
An HTTP error occurred when trying to retrieve this URL. HTTP errors
are often intermittent, and a simple retry will get you on your way.
ConnectTimeout(MaxRetryError("HTTPSConnectionPool(host='repo.continuum.io',
port=443): Max retries exceeded with url:
/pkgs/main/win-64/repodata.json.bz2 (Caused by
ConnectTimeoutError(, 'Connection to repo.continuum.io timed out.
(connect timeout=9.15)'))",),)
Error: Error 1 occurred creating conda environment r-tensorflow In
addition: Warning message: running command
'"C:\PROGRA~3\ANACON~1\Scripts\conda.exe" "create" "--yes" "--name"
"r-tensorflow" "python=3.6"' had status 1
I've looked up everywhere on the web and can't figure out how to install keras and tensorflow properly. Using latest version of R (3.4.2)
Every method fails somewhere.
just to add to misery, i've also tried:
> devtools::install_github("rstudio/keras")
and i get this error:
Installation failed: Timeout was reached: Connection timed out after
10015 milliseconds
I am not behind any authenticated proxies. So, after multiple failure, i just downloaded the zip file from github and manually installed it using the zip file.
i also tried install.packages("keras") and that didn't give me any error either.
when i call the library i don't get any errors (as shown above)
UPDATE: I was able to install and use the package very easily on another computer that doesn't have python/anaconda installed on it already.
UPDATE 2: my proxy does not need authentication and there is no https_proxy either.
OK,, FINALLY found a solution.
Turns out RStudio uses a lot of default proxy settings, so i needed to change all that and set up my own proxy settings.
First step:
Rstudio --> Tools --> Global Options --> packages --> uncheck both "Use secure download method for HTTP" and "Use Internet Explorer librayr/proxy for HTTP"
Second step, in RStudio type:
> file.edit('./.Renviron')
Either an empty file or some file with already existing proxy settings will open. (Mine was empty). Then I included the following two:
http_proxy=http://myusename:password#proxy.server.com:port/
https_proxy=http://myusename:password#proxy.server.com:port/
(a few notes: I didn't have a https_proxy setting but I still needed to use the http_proxy details for my https_proxy setting. This was one of the culprits for my issue. Also, I needed to include the username:password even though my proxy doesn't need secure authentication. Same thing goes with the port. Port number had to be included, otherwise it wouldn't work.
Step 3:
Saved the new changes in .Renviron file and restarted RStudio.
I checked my proxy settings in RStudio after restart by typing:
> Sys.getenv("http_proxy")
> Sys.getenv("https_proxy")
The first few times i did this i realised that the proxy settings were not being changed in RStudio because i was editing the wrong .Renviron file. So, it's best to use file.edit('~/.Renviron') in step 2 to make sure it's the right file.
After all this, when i ran install.keras(), it installed successfully, including installing Tensorflow. Again, initially i had skipped step 1 so keras started being installed but it failed at installing tensorflow.
It was only going through all the steps that i was able to install both keras and tensorflow successfully over a proxy. Hope this helps.
Uninstalling Anaconda3 and installing Anaconda2 (i.e. Python 2.7) did the trick for me: https://www.anaconda.com/download/

Resources