snooppy / lastfm-java

Last.fm API bindings for Java
BSD 2-Clause "Simplified" License
1 stars 1 forks source link

Exception while trying get all tracks via Library util #1

Open snooppy opened 11 years ago

snooppy commented 11 years ago

While executing Library.getTracks(...), Library.getAllTracks(...) I get exception: Exception in thread "main" de.umass.lastfm.CallException: java.net.SocketException: Unexpected end of file from server

Post in both cases looks like: INFO: Post body: method=library.getTracks&limit=0&page=1&api_key=key&user=user

Stacktrace: Exception in thread "main" de.umass.lastfm.CallException: java.net.SocketException: Unexpected end of file from server at de.umass.lastfm.Caller.call(Caller.java:251) at de.umass.lastfm.Caller.call(Caller.java:189) at de.umass.lastfm.Library.getTracks(Library.java:216) at de.umass.lastfm.Library.getTracks(Library.java:199) at de.umass.lastfm.Library.getAllTracks(Library.java:232) at com.dmitrykrivenko.testmavenproject.App.main(App.java:48) Caused by: java.net.SocketException: Unexpected end of file from server at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:718) at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:579) at sun.net.www.http.HttpClient.parseHTTPHeader(HttpClient.java:715) at sun.net.www.http.HttpClient.parseHTTP(HttpClient.java:579) at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1322) at java.net.HttpURLConnection.getResponseCode(HttpURLConnection.java:468) at de.umass.lastfm.Caller.getInputStreamFromConnection(Caller.java:312) at de.umass.lastfm.Caller.call(Caller.java:231) ... 5 more

I'm using the latest version of the library (0.1.2). OS - Ubuntu 12.04.

snooppy commented 11 years ago

I think it happens, because default limit in the method Library.getTracks(...) is setted as 0. And when server receives this request it tries to get All tracks from the library. But if library is a big, like in my case, server tries to send a very big xml to us, and this causes the error I described above. The same error we can get in method getArtists(), getAlbums(). So, I'm offering to set DEFAULT_PAGE and DEFAULT_LIMIT (see my ISSUE-53.patch). And also I'm offering to remove all methods getAll*() from Library to prevent excess load on the server and to prevent such errors I got.