Retrofit: Strange behavior: Unexpected end of stream with retrofit 2.1.0

Created on 14 Jul 2016  路  2Comments  路  Source: square/retrofit

My REST API return data likes below

[{ "metadata": 
   { "type": 1,
     "taken_at": "2015-08-25T04:58:04.000Z",
     "size": 235315,
     "filename": "5787318d0321444d452ec986.jpg" },
  "created_at": "2016-07-14T06:46:45.135Z",
  "updated_at": "2016-07-14T06:46:45.135Z",
  "data": "{base64 encoded data}",
}]

and here is my interceptor

Request.Builder requestBuilder = original.newBuilder()
        .header("Accept", "application/json")
        .header("Content-Type","application/json; charset=utf-8")
        .header("Authorization", token.getTokenType() + " " + token.getAccessToken())
        .method(original.method(), original.body());

Request request = requestBuilder.build();
return chain.proceed(request);

Somehow, when response is large (around ~500KB), IOException: unexpected end of stream is thrown in onFailure(). More strangely, the exception is not always being thrown for the same request.
Sometime it succeeds, most of the time not.
I wonder the response's size is the problem here. If it is, could I increase the response size limit?

Most helpful comment

There is no limit, and Retrofit isn't in control of anything that happens at the HTTP client level.

This seems like https://github.com/square/okhttp/issues/2738.

All 2 comments

There is no limit, and Retrofit isn't in control of anything that happens at the HTTP client level.

This seems like https://github.com/square/okhttp/issues/2738.

I also have the same problem did you get answer for this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ne1c picture Ne1c  路  3Comments

bolds07 picture bolds07  路  3Comments

chriskessel picture chriskessel  路  3Comments

bhagyasri picture bhagyasri  路  3Comments

kkunsue picture kkunsue  路  3Comments