entriphy / sp-playcount-librespot

Modification of librespot-java to provide play count info from Spotify
Apache License 2.0
119 stars 16 forks source link

[bug] JSON occasionally fails to parse #2

Open entriphy opened 4 years ago

entriphy commented 4 years ago

Stack trace:

com.google.gson.JsonSyntaxException: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 5 path $
 at com.google.gson.JsonParser.parseReader(JsonParser.java:66)
 at xyz.gianlu.librespot.mercury.JsonMercuryRequest.instantiate(JsonMercuryRequest.java:26)
 at xyz.gianlu.librespot.mercury.MercuryClient.sendSync(MercuryClient.java:82)
 at xyz.gianlu.librespot.HTTPSServer$PlayCountHandler.handle(HTTPSServer.java:88)
 at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
 at sun.net.httpserver.AuthFilter.doFilter(AuthFilter.java:83)
 at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:82)
 at sun.net.httpserver.ServerImpl$Exchange$LinkHandler.handle(ServerImpl.java:675)
 at com.sun.net.httpserver.Filter$Chain.doFilter(Filter.java:79)
 at sun.net.httpserver.ServerImpl$Exchange.run(ServerImpl.java:647)
 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
 at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
 at java.lang.Thread.run(Thread.java:748)
Caused by: com.google.gson.stream.MalformedJsonException: Use JsonReader.setLenient(true) to accept malformed JSON at line 1 column 5 path $
 at com.google.gson.stream.JsonReader.syntaxError(JsonReader.java:1564)
 at com.google.gson.stream.JsonReader.checkLenient(JsonReader.java:1405)
 at com.google.gson.stream.JsonReader.doPeek(JsonReader.java:543)
 at com.google.gson.stream.JsonReader.peek(JsonReader.java:426)
 at com.google.gson.JsonParser.parseReader(JsonParser.java:61)
 ... 12 more
slapheadted commented 4 years ago

What's the response code that you get back from the server for this issue @evilarceus ? Would it result in a 500? (As I mentioned in response to another issue here) I'm experiencing intermittent 500s from the public server.

entriphy commented 4 years ago

The status code should be 500 for this issue. If you're getting random status code 500s, it's most likely because of this issue.

annadnl commented 4 years ago

i'm also getting intermittent 500s on the artistInfo endpoint

2020/04/29 09:09:41 [warn] 4576#0: *1244 an upstream response is buffered to a temporary file /var/lib/nginx/tmp/proxy/1/00/0000000001 while reading upstream, client: 87.9.212.241, server: , request: "GET /artistInfo?artistid=0SfsnGyD8FpIN4U4WCkBZ5 HTTP/1.1", upstream: "http://xxx/artistInfo?artistid=0SfsnGyD8FpIN4U4WCkBZ5", host: "xxx", referrer: "http://xxx/artistInfo?artistid=0SfsnGyD8FpIN4U4WCkBZ5"

Stoley commented 4 years ago

i'm also getting intermittent 500s on the artistInfo endpoint

2020/04/29 09:09:41 [warn] 4576#0: *1244 an upstream response is buffered to a temporary file /var/lib/nginx/tmp/proxy/1/00/0000000001 while reading upstream, client: 87.9.212.241, server: , request: "GET /artistInfo?artistid=0SfsnGyD8FpIN4U4WCkBZ5 HTTP/1.1", upstream: "http://xxx/artistInfo?artistid=0SfsnGyD8FpIN4U4WCkBZ5", host: "xxx", referrer: "http://xxx/artistInfo?artistid=0SfsnGyD8FpIN4U4WCkBZ5"

That's a playlist

annadnl commented 4 years ago

it is not, it's armin van buuren :-)

spotify:artist:0SfsnGyD8FpIN4U4WCkBZ5

but you are correct, if you search for "0SfsnGyD8FpIN4U4WCkBZ5" on the platform it does return a playlist. could this be a hint towards where the problem comes from? that a playlist and an artist have the same handle?

Stoley commented 4 years ago

ah you're right, never seen that before