ropensci / rentrez

talk with NCBI entrez using R
https://docs.ropensci.org/rentrez
Other
195 stars 38 forks source link

Timeout was reached #87

Closed tobigithub closed 8 years ago

tobigithub commented 8 years ago

Hi, just doing the demos from https://ropensci.org/tutorials/rentrez_tutorial.html Is there any way to avoid the timeout error? This is on a fast connection.

> library("rentrez")
> another_r_search <- entrez_search(db="pubmed", term="R Language", retmax=40)

Error in curl::curl_fetch_memory(url, handle = handle) : 
  Timeout was reached

Thanks. Tobias

dwinter commented 8 years ago

Hi Tobias, where you able to run some of the other small examples (e.g. entrez_db_searchable("sra") )?

With a small request like this, that error likely means there was an intermittent error with the NCBI or your connection. Can you try it again at let me know if it's resolved itself or not?

tobigithub commented 8 years ago

HI, just running all the examples, sometimes it works sometimes not, also waited a couple minutes. The error pops up here and then, I also checked on another machine, It could be related to the internal network and or all the firewalls, or maybe related traffic to entrez.

Therefore tuning a parameter to allow for more time would be interesting (if there is such a function).

> 
> search_year <- function(year, term){
+     query <- paste(term, "AND (", year, "[PDAT])")
+     entrez_search(db="pubmed", term=query, retmax=0)$count
+ }
> 
> year <- 2000:2015
> papers <- sapply(year, search_year, term="Connectome", USE.NAMES=FALSE)
Error in curl::curl_fetch_memory(url, handle = handle) : 
  Timeout was reached
> 
> plot(year, papers, type='b', main="The Rise of the Connectome")
Error in plot(year, papers, type = "b", main = "The Rise of the Connectome") : 
  object 'papers' not found
dwinter commented 8 years ago

Hi again Tobias,

The timeout is being returned by curl via httr. For most functions you can set any httr or curl options using config=httr::config(...). The options that can be pased to httr::config are listed in httr::httr_options().

To be honest, I don't know exactly how the (various different) timeout options work, you may have to read the libcurl manual to get to the bottom of that.

More generally, it's unusual to get these errors consistently, especially on short requests like the one at the top of this issue. It may be a sympton of something else going on with your network or on the NCBI's servers.

tobigithub commented 8 years ago

Thank you! Tobias