Why do I always get the connection error with fromJSON
? Sometimes it is fine. Most of time it is not.
> # Load json and other packages.
> library(jsonlite)
>
> # Live server.
> server <- 'http://0.0.0.0:3000'
> # Stream 143
> key <- '9p06nngO2pcQM03nIJ71dLXNA1v'
>
> # Retrieve json data from the data platform via the URLs.
> streams <- fromJSON(paste(server, '/output/streams', sep=""), flatten=TRUE)
Result:
Error in open.connection(con, "rb") : Couldn't connect to server
If I try again:
> streams <- fromJSON(paste(server, '/output/streams', sep=""), flatten=TRUE)
Error:
Error in open.connection(con, "rb") : Server returned nothing (no headers, no data)
But the server is fine. It is up and running.
Any ideas how I can fix this?
Or any other better and more reliable package for getting the json data from the server?