• snupicel over 4 years ago


    I'm using Volley library to send requests to discogs.
    Collections, releases, artists and a few others work very well.
    I have had no weird status responses or exceptions.

    Until now. I'm making a request for a users folder list with:

    1 out of 3 times I'm getting a EndOfFile Exception.

    Sometimes it works for 3-4 times in a row. Sometimes not. It's pretty random.

    I just want to know if it's Discogs at fault or me.

    Here's some stacktrace:

    09-21 21:28:46.456 26428-26428/com.example.florareasca.discogs I/System.out﹕ entering onErrorResponse
    09-21 21:28:46.457 26428-26428/com.example.florareasca.discogs W/System.err﹕ com.android.volley.NoConnectionError: java.io.EOFException
    09-21 21:28:46.457 26428-26428/com.example.florareasca.discogs W/System.err﹕ at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:134)
    09-21 21:28:46.458 26428-26428/com.example.florareasca.discogs W/System.err﹕ at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:110)
    09-21 21:28:46.458 26428-26428/com.example.florareasca.discogs W/System.err﹕ Caused by: java.io.EOFException


  • rodneyfool over 4 years ago

    Hi snupicel,

    Are you limiting your requests to 1 per second? You might be getting this response if you are sending too many requests at one time. Please see the rate-limiting section of the API docs for more info if this is the case

  • djerom over 4 years ago

    I'm facing the same issue.

    com.android.volley.NoConnectionError: java.io.EOFException
    at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:134)
    at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:110)
    Caused by: java.io.EOFException
    at com.android.okhttp.internal.Util.readAsciiLine(Util.java:318)
    at com.android.okhttp.internal.http.RawHeaders.fromBytes(RawHeaders.java:308)
    at com.android.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:135)
    at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:644)
    at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:347)
    at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:296)
    at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:503)
    at com.android.volley.toolbox.HurlStack.performRequest(HurlStack.java:109)
    at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:93)
                at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:110)

    With the Volley API, you could set your own RetryPolicy in you Request but it doesn't apply to the NoConnectionError (  SEE com.android.volley.toolbox.BasicNetwork#performRequest(Request<?>) }).

    It seems the Http Response is null so it throws a NoConnectionError.

    So I don't see a easy way to handle this case.
  • djerom over 4 years ago

    By the way, since the Http Response is null we can not catch the Http Code 429 "Too Many Requests".
  • snupicel over 4 years ago

    Are you limiting your requests to 1 per second? You might be getting this response if you are sending too many requests at one time. Please see the rate-limiting section of the API docs for more info if this is the case

    That is exactly the problem. I'm using the Vollley library and it handles the requests in a pool of 4 threads in parallel. I had no idea it does that until I searched around. Anyway, thanks a bunch, it was driving me nuts.

  • snupicel over 4 years ago


    Now you're probably wondering how to limit the thread pool size to just 1 thread so the RequestQueue won't make simultaneous requests. Well, after struggling for a few hours and digging through the volley source code I managed to find a solution.

    You actually have to manually construct RequestQueue.

    Here's the code:

    File cacheDir = new File(getApplicationContext().getCacheDir(), "volley");
    Network network = new BasicNetwork(new OAuthStack(consumer));
    mRequestQueue = new RequestQueue(new DiskBasedCache(cacheDir), network, 1);

    Here "1" is the number of threads you want in the pool. It's set to 1 to avoid 2 parallel requests. However, I think you shouldn't use this 1 thread RequestQueue for downloading images for example, because it will severely impact performance.

    Oh, and OAuthStack is just a httpstack I'm using. You can replace it with yours or a default one.
  • djerom over 4 years ago

    @ snupicel

    Thank for sharing your code. It helps.
  • djerom over 4 years ago

    But the current rate limitating policy doesn't help to implement a responsive application.
  • snupicel over 4 years ago

    I managed to implement a pretty responsive application.

    Maybe your implementation is at fault. Care to elaborate on your issues?
  • djerom over 4 years ago

    For example I'm using the ViewPager view in which I create fragments which request Discogs URLs.
    The worker of the Volley API let us use multiple network dispatcher threads and it's frustating to limitate them to a single one.
    My application is also pretty responsive but it could be better.
  • oauthsucks over 4 years ago

    oauthsucks edited over 4 years ago
    Rate limiting + paging pretty much kills responsiveness the first time. It also guarantees that everyone will cache that data for the second time. :-)
  • snupicel over 4 years ago


    It seems my issue has come back. I have implemented a background service that downloads a user's whole collection. I'm sending one request at a time, process it (Json -> pojo -> Database), after 4-5 seconds of process send next request and so on. I'm still getting EOFE at every couple of requests. Sending multiple requests per second is out of the question as it takes minimum 5 seconds for processing each one and I've implemented a separate, single threaded request queue. I'm 100% sure there are no simultanous requests.

    Do you have any idea what else could be causing this EOF exceptions?
  • djerom over 4 years ago

    I'm still facing this issue.

    Stack trace:

    com.android.volley.NoConnectionError: java.io.EOFException
    at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:151)
    at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112)
    Caused by: java.io.EOFException
    at com.android.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:95)
    at com.android.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:175)
    at com.android.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:101)
    at com.android.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:616)
    at com.android.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:379)
    at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:323)
    at com.android.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:491)
    at com.android.volley.toolbox.HurlStack.performRequest(HurlStack.java:109)
    at com.android.volley.toolbox.BasicNetwork.performRequest(BasicNetwork.java:96)
                at com.android.volley.NetworkDispatcher.run(NetworkDispatcher.java:112)

    Source code for com.android.okio.RealBufferedSource.readUtf8LineStrict(RealBufferedSource.java:95):
      override public String readUtf8LineStrict() throws IOException {
    long newline = indexOf((byte) '\n');
    if (newline == -1L) throw new EOFException();
    return buffer.readUtf8Line(newline);

    It seems sometimes the newline character is missing in the response.

Log In You must be logged in to post.