Error in open.connection(con, open = mode) : Timeout was reached: [github.com]

Summary:

I am receiving this type of error (with slight variations, as shown in Current Output, below) in the R console during the warmup portion of sampling during the execution of a stan function call:

Error in open.connection(con, open = mode) : 
  Timeout was reached: [github.com] Operation timed out after 13129 milliseconds with 0 out of 0 bytes received

I get why it would have trouble connecting (I’m behind a pretty strict firewall at work), but I don’t understand why it’s trying to connect in the first place or whether this is affecting the sampling progress (which seems to be way too slow, relative to the estimates from the chains).

Description:

I coded a sizeable model in a .stan file and then called the RStan function stan to compile and sample from it. After it had been attempting to sample for about an hour I got a series of error/warning messages (see Current Output, below). There is no termination of the script; it still shows as running in R.

Reproducible Steps:

The .stan and .r files involved are attached at the link below. I am unfortunately not allowed to attach the input data, as it is the property of my employer and not myself.
draft_cda2_ohi_analysis_2.zip

Current Output:

Error in open.connection(con, open = mode) : 
  Timeout was reached: [github.com] Operation timed out after 13129 milliseconds with 0 out of 0 bytes received
In addition: Warning message:
In system(paste(CXX, ARGS), ignore.stdout = TRUE, ignore.stderr = TRUE) :
  'C:/rtools40/usr/mingw_/bin/g++' not found
Error in open.connection(con, open = mode) : 
  Timeout was reached: [github.com] Operation timed out after 13328 milliseconds with 0 out of 0 bytes received
Error in open.connection(con, open = mode) : 
  Timeout was reached: [github-releases.githubusercontent.com] Connection timed out after 38982 milliseconds
Error in open.connection(con, open = mode) : 
  Timeout was reached: [github.com] Resolving timed out after 14366 milliseconds
Error in open.connection(con, open = mode) : 
  Timeout was reached: [github.com] Operation timed out after 14470 milliseconds with 0 out of 0 bytes received

The second warning is nothing new - I get that every time and it doesn’t affect anything. It’s the other output I’m concerned about.

Expected Output:

N/A

RStan Version:

2.21.2

R Version:

R version 4.1.0 (2021-05-18)

Operating System:

Windows 10 Enterprise, OS Build 19041.985

2 Likes

Hi,
Thank you for describing this issue. I’m experiencing the same and I am interested in why this is happening.
Ana

I haven’t seen this before. @bgoodri or @hsbadr any ideas why RStan is doing this?

If this is preventing you from fitting Stan models in R you could try switching to our other R interface CmdStanR, which shouldn’t have this problem:

I don’t think this is related to RStan, but I can help. It’s most likely due to one or more of the following issues, specifically on Windows:

  1. R tools/toolchain issue (or compilers aren’t installed/found):
    'C:/rtools40/usr/mingw_/bin/g++' not found
  1. Use environment (e.g., Makevars, Rprofile, … etc.) and R dependencies (e.g., packages linked to old version of R which usually happens when the user upgrades R with cleanly reinstalling all packages).
  2. Character encoding for paths (e.g., the home or Temp directory path include spaces or special characters).

The easiest solution that may take some time but will work without troubleshooting is to address the 3 issues above, if applicable, and cleanly install R + Rtools and make sure the correct version is on the PATH: Using Rtools40 on Windows. Otherwise, we need to troubleshoot them one by one starting with creating a Temp file and checking its path. Then, test that g++ exists and works.

Unfortunately, RStan requires compilation at runtime and so it depends on the R toolchain and user environment. I’m thinking of creating a private environment for RStan (that would likely support other Stan interfaces/packages in R) but I don’t have enough time right now.

1 Like

Sorry for not getting to this sooner. This is caused by RStan 2.21 checking whether your Stan model will compile using the next version of the Stan compiler. It does this by downloading a compiler binary from Github. But if your network disallows this, then it can fail with an error (this is what happens on my work network).

Two solutions here. Firstly, you can disable the check by running:

rstan_options(javascript=FALSE)

Alternatively, you can try the preview of the next Rstan version which already uses the new compiler and so doesn’t contact github:

remove.packages(c("StanHeaders", "rstan"))
install.packages("StanHeaders", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))
install.packages("rstan", repos = c("https://mc-stan.org/r-packages/", getOption("repos")))

3 Likes