ncss-tech / soilDB

soilDB: Simplified Access to National Cooperative Soil Survey Databases
http://ncss-tech.github.io/soilDB/
GNU General Public License v3.0
81 stars 20 forks source link

bad error for gateway time out #339

Closed araiho closed 8 months ago

araiho commented 8 months ago

For fetchSoilGrids(), I'm getting the following error when the URL https://rest.isric.org/soilgrids/v2.0/properties/ can't be accessed which could be replaced with a better error message about the URL not working.

Error: lexical error: invalid char in json text.

504 Gatewa (right here) ------^ Is there a backup for when this website is down? </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/brownag"><img src="https://avatars.githubusercontent.com/u/20842828?v=4" />brownag</a> commented <strong> 8 months ago</strong> </div> <div class="markdown-body"> <blockquote> <p>For fetchSoilGrids(), I'm getting the following error when the URL <a href="https://rest.isric.org/soilgrids/v2.0/properties/">https://rest.isric.org/soilgrids/v2.0/properties/</a> can't be accessed which could be replaced with a better error message about the URL not working.</p> <p>Error: lexical error: invalid char in json text. <title>504 Gatewa (right here) ------^</p> </blockquote> <p>Thanks for reporting this, I can adjust the function so that when this type of non-JSON HTML error response is received the error is properly trapped rather than passed on for parsing. </p> <p>Unfortunately its really common for total failures of APIs like this to regress to a non-JSON response, hence the lexical error. Normal error messages issued by a functioning API are already handled.</p> <blockquote> <p>Is there a backup for when this website is down?</p> </blockquote> <p>Unfortunately there is no complete alternative to the REST API endpoint. Please contact ISRIC as they are the ones responsible for the endpoint (and the response when it fails)</p> <p>From the SoilGrids FAQ <a href="https://www.isric.org/explore/soilgrids/faq-soilgrids">https://www.isric.org/explore/soilgrids/faq-soilgrids</a></p> <blockquote> <p>NOTE: We are closing down an old domain "soilgrids.isric.org". Please make sure that you use the current domain "soilgrids.org"</p> </blockquote> <p>It is not clear at this time whether the above notice is indicating that the REST API has moved (or will move). A couple years ago the API was accessible via soilgrids.org and they changed to the current rest.isric.org URL.</p> <p>There have been significant periods of downtime in past years, not much anyone but ISRIC can do about it. Note also that there is a "Fair Use" limit of ~5 requests per minute... but this 504 error is unrelated to that. The entire rest.isric.org site appears to return the same 504 error.</p> <p>I will provide an option in <code>fetchSoilGrids()</code> to specify an alternate endpoint if someone was interested in mirroring the REST service elsewhere; but providing an alternate source is out of scope for this R package, in general.</p> <p>In the meantime you could consider using the <code>grid=TRUE</code> argument to make requests directly to the cloud optimized geotiffs found here <a href="https://files.isric.org/soilgrids/latest/data/">https://files.isric.org/soilgrids/latest/data/</a>. I recognize this is not a direct replacement for the point-based queries to the REST API, as it returns grids covering an area, rather than a point. Also even for small areas it will take some time to get the information for all properties analogous the point query. To use this approach you would need to buffer an area around your point(s) of interest, download the grids, then extract the values at target point locations.</p> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/brownag"><img src="https://avatars.githubusercontent.com/u/20842828?v=4" />brownag</a> commented <strong> 8 months ago</strong> </div> <div class="markdown-body"> <p>Thanks again for reporting, after 0a7cc90c I get:</p> <pre><code class="language-r">library(soilDB) your.points <- data.frame(id = c("A", "B"), lat = c(37.9, 38.1), lon = c(-120.3, -121.5), stringsAsFactors = FALSE) x <- fetchSoilGrids(your.points, verbose=TRUE) #> Error : lexical error: invalid char in json text. #> <html> <head><title>504 Gatewa #> (right here) ------^ #> #> Error : lexical error: invalid char in json text. #> <html> <head><title>504 Gatewa #> (right here) ------^ #> #> Error : SoilGrids API is not accessible inherits(x, 'try-error') #> [1] TRUE</code></pre> </div> </div> <div class="comment"> <div class="user"> <a rel="noreferrer nofollow" target="_blank" href="https://github.com/araiho"><img src="https://avatars.githubusercontent.com/u/3520982?v=4" />araiho</a> commented <strong> 8 months ago</strong> </div> <div class="markdown-body"> <p>Cool! Thanks for adding that and for the detailed response!</p> </div> </div> <div class="page-bar-simple"> </div> <div class="footer"> <ul class="body"> <li>© <script> document.write(new Date().getFullYear()) </script> Githubissues.</li> <li>Githubissues is a development platform for aggregating issues.</li> </ul> </div> <script src="https://cdn.jsdelivr.net/npm/jquery@3.5.1/dist/jquery.min.js"></script> <script src="/githubissues/assets/js.js"></script> <script src="/githubissues/assets/markdown.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/highlight.min.js"></script> <script src="https://cdn.jsdelivr.net/gh/highlightjs/cdn-release@11.4.0/build/languages/go.min.js"></script> <script> hljs.highlightAll(); </script> </body> </html>