Retrofit POST java.io.EOFException

1.4k views Asked by At

I'm trying to do a POST request to my server with a json body. If my POST request does not have body, it works. If I have any body content, I get this EOFException. Please let me know if I missed any detail.

retrofit version 1.5.0
okhttp version 1.5.2

Message model:

public static class MyMessage{
    String local;
}

retrofit post:

@POST("/user/{user_id}/message")
void createMessage(
        @Path("user_id") long user_id,
        @Body MyMessage json,
        MyCallback cb);

Log error:

06-10 18:25:18.575: D/Retrofit(28598): ---> HTTP POST XXX/user/1111158/message
06-10 18:25:18.575: D/Retrofit(28598): Content-Type: application/json; charset=UTF-8
06-10 18:25:18.575: D/Retrofit(28598): Content-Length: 16
06-10 18:25:18.576: D/Retrofit(28598): {"local":"xyzw"}
06-10 18:25:18.576: D/Retrofit(28598): ---> END HTTP (16-byte body)
06-10 18:25:18.579: D/Retrofit(28598): ---- ERROR XXX/user/1111158/message
06-10 18:25:18.581: D/Retrofit(28598): java.io.EOFException
06-10 18:25:18.581: D/Retrofit(28598):  at com.squareup.okhttp.internal.okio.RealBufferedSource.readUtf8Line(RealBufferedSource.java:90)
06-10 18:25:18.581: D/Retrofit(28598):  at com.squareup.okhttp.internal.http.HttpConnection.readResponse(HttpConnection.java:145)
06-10 18:25:18.581: D/Retrofit(28598):  at com.squareup.okhttp.internal.http.HttpTransport.readResponseHeaders(HttpTransport.java:99)
06-10 18:25:18.581: D/Retrofit(28598):  at com.squareup.okhttp.internal.http.HttpEngine.readResponse(HttpEngine.java:568)
06-10 18:25:18.581: D/Retrofit(28598):  at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.execute(HttpURLConnectionImpl.java:372)
06-10 18:25:18.581: D/Retrofit(28598):  at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponse(HttpURLConnectionImpl.java:319)
06-10 18:25:18.581: D/Retrofit(28598):  at com.squareup.okhttp.internal.http.HttpURLConnectionImpl.getResponseCode(HttpURLConnectionImpl.java:484)
06-10 18:25:18.581: D/Retrofit(28598):  at retrofit.client.UrlConnectionClient.readResponse(UrlConnectionClient.java:71)
06-10 18:25:18.581: D/Retrofit(28598):  at retrofit.client.UrlConnectionClient.execute(UrlConnectionClient.java:38)
06-10 18:25:18.581: D/Retrofit(28598):  at retrofit.RestAdapter$RestHandler.invokeRequest(RestAdapter.java:358)
06-10 18:25:18.581: D/Retrofit(28598):  at retrofit.RestAdapter$RestHandler.access$100(RestAdapter.java:264)
06-10 18:25:18.581: D/Retrofit(28598):  at retrofit.RestAdapter$RestHandler$2.obtainResponse(RestAdapter.java:315)
06-10 18:25:18.581: D/Retrofit(28598):  at retrofit.CallbackRunnable.run(CallbackRunnable.java:42)
06-10 18:25:18.581: D/Retrofit(28598):  at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
06-10 18:25:18.581: D/Retrofit(28598):  at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
06-10 18:25:18.581: D/Retrofit(28598):  at java.lang.Thread.run(Thread.java:841)
06-10 18:25:18.581: D/Retrofit(28598): ---- END ERROR
0

There are 0 answers