NEONScience / NEON-utilities

Utilities and scripts for working with NEON data. Currently: an R package with functions to join (stack) the month-by-site files in downloaded NEON data, to convert data to geoCSV format, and to download data from the API.
GNU Affero General Public License v3.0
57 stars 36 forks source link

No internet connection. Cannot access NEON API. #132

Closed jswesner closed 2 months ago

jswesner commented 2 months ago

Hi - We are getting this error on multiple machines, when running the tutorial code from here:https://www.neonscience.org/resources/learning-hub/tutorials/download-explore-neon-data

parlist <- loadByProduct(dpID="DP1.00024.001", site="WREF", startdate="2019-09", enddate="2019-11")

'No internet connection. Cannot access NEON API.'

We do have internet and it does not work even if we use our NEON token.

cklunch commented 2 months ago

@jswesner Thanks for getting in touch about this. The neonUtilities package uses curl::has_internet() to check whether the user has internet access before it tries to download anything, and in rare cases curl::has_internet() returns FALSE even when a connection is available. There are a variety of reasons why this might happen, so rather than try to figure out the root cause, it's easiest to just force the function to return TRUE and proceed. The simplest way to do that is to run

assign("has_internet_via_proxy", TRUE, environment(curl::has_internet))

before running the neonUtilities code. For more examples and other ways of getting around curl::has_internet(), this StackOverflow post is helpful https://stackoverflow.com/questions/59796178/r-curlhas-internet-false-even-though-there-are-internet-connection

Let us know if this solves the problem!

jswesner commented 2 months ago

That worked. Thanks @cklunch!