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?
It seems to me that there is some special character in the
public_key
field. For instance:Burl
andGurl
are only apparently the same:You can inspect the
raw
content of the above urls (withcharToRaw
) and check theEncoding
to spot the differences.Eg. Php, basic just get data from server by json_encode What programming languages are u using? For back-end