I am using HttpsURLConnection which uses okhttp, and everytime I use PUT and send a payload of around 5KB it sends it without any errors; nevertheless, when I send larger payloads of over 10KB, I would get the following error:
W/System.err: java.net.ProtocolException: unexpected end of stream
W/System.err: at com.android.okhttp.internal.http.HttpConnection$FixedLengthSink.close(HttpConnection.java:314) W/System.err: at com.android.okhttp.okio.RealBufferedSink.close(RealBufferedSink.java:241) W/System.err: at com.android.okhttp.okio.RealBufferedSink$1.close(RealBufferedSink.java:209) W/System.err: at java.io.FilterOutputStream.close(FilterOutputStream.java:67)
W/System.err: at com.mercadolibre.android.sdk.internal.HttpPut.performOperationBeforeConnect(HttpPut.java:52) W/System.err: at com.mercadolibre.android.sdk.internal.HttpOperation.execute(HttpOperation.java:100) W/System.err: at com.mercadolibre.android.sdk.internal.HttpOperation.execute(HttpOperation.java:74) W/System.err: at com.mercadolibre.android.sdk.Meli.put(Meli.java:534)
W/System.err: at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) W/System.err: at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) W/System.err: at java.lang.Thread.run(Thread.java:818)
Upon retrying to send it, it would eventually work, somestimes taking up to 5 re-tries which suggest that the payload is not corrupt nor anything but an error on the connection.
Any idea on what might be causing it? I have reviewed the library and I call flush() and close() after writing so the Sink should not be having any size errors.Addtionally I have tried setting up a fixedsize for the connection to use the length of my payload, but nothing seems to work.
Thank you in advance.