epiforecasts / covidregionaldata

An interface to subnational and national level COVID-19 data. For all countries supported, this includes a daily time-series of cases. Wherever available we also provide data on deaths, hospitalisations, and tests. National level data is also supported using a range of data sources as well as linelist data and links to intervention data sets.
https://epiforecasts.io/covidregionaldata/
Other
37 stars 18 forks source link

HTTP error 502 when downloading Vietnam's json data #426

Closed biocyberman closed 2 years ago

biocyberman commented 2 years ago

I am investigating the error. It seems that the return data is not fully validated JSON. Data can be viewed directly via browser but failed when downloaded with fromJSON. For example:

library(purrr)
library(tidyr)
library(lubridate)
library(stringr)
library(stringi)
library(jsonlite)
data_urls = list(
      "provinces" = "https://covid.ncsc.gov.vn/api/v3/covid/provinces",
      "case_by_time" = "https://covid.ncsc.gov.vn/api/v3/covid/provinces?filter_type=case_by_time"
    )
json_reader <- function(file, verbose = FALSE, ...) {
        if (verbose) {
          message("Downloading data from ", file)
          data <- fromJSON(file, ...)
        } else {
          data <- suppressWarnings(
            suppressMessages(
              fromJSON(file, simplifyDataFrame = TRUE, flatten = TRUE)
            )
          )
        }
        return(tibble(data))
      } 
data = map(data_urls, json_reader)

Gave: Error in open.connection(con, "rb") : HTTP error 502.

github-actions[bot] commented 2 years ago

Thanks for opening an issue! We'll try and get back to you shortly. If you've identified an issue and would like to fix it please see our contribution guidelines.

RichardMN commented 2 years ago

Looking at it and having tried a few variant URLs I think this may be a glitch upstream on the server end. I get 502 for just about any URL going to the API directory, though not to the top level one, which could be consistent with the API urls being redirected to a specific server or port and that port failing. (E.g., https://bobcares.com/blog/502-bad-gateway-nginx/) I think we may wait twelve hours and see. (Though when this happened with Germany I think I wrote my first implementation of a JSON downloader and had it running roughly in time for the problem to fix itself upstream.)

biocyberman commented 2 years ago

I reported to NCSC colleages.

seabbs commented 2 years ago

Looks like this may have cleared up on the latest automated check so sounds like it was server side.

biocyberman commented 2 years ago

The problem is gone even though I haven't got a reply from NCSC :)

trilwu commented 2 years ago

Hello from NCSC. It is an honor for us to have this data contributed to your project.

The stable domain is covid19.ncsc.gov.vn, the old URL: covid.ncsc.gov.vn (beta) is now deprecated. We have reopened for a few days so you can update the new URL. I made a pull request here https://github.com/epiforecasts/covidregionaldata/pull/427