They asked a couple of questions, but I have not yet found a real answer. I have an Android code that runs NetHttpRequest to send an image to a server, but it often doesn’t work quickly like this:
unexpected end of stream java.io.IOException: unexpected end of stream at libcore.net.http.FixedLengthOutputStream.close(FixedLengthOutputStream.java:58) at com.google.api.client.http.javanet.NetHttpRequest.execute(NetHttpRequest.java:84) at com.google.api.client.http.HttpRequest.execute(HttpRequest.java:1009) at com.test.MyActivity$ImageUploadTask.doInBackground(MyActivity.java:870) at com.test.MyActivity$ImageUploadTask.doInBackground(MyActivity.java:1) at android.os.AsyncTask$2.call(AsyncTask.java:287) at java.util.concurrent.FutureTask$Sync.innerRun(FutureTask.java:305) at java.util.concurrent.FutureTask.run(FutureTask.java:137) at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:230) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1076) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:569) at java.lang.Thread.run(Thread.java:856)
I don’t understand ... why so bad? Given the feedback, it seems to me that it should have something to do with the HTTP library, closing the connection prematurely, but I cannot determine why. Most related questions have exactly the same problem (for example, downloading jpeg to Google Drive from an Android application and unexpected end of stream ), unless the question goes unanswered or the crawler finds some strange workaround that seems to be solves it for them (although probably they are just lucky).
My download code is not special, just AsyncTask that creates the HttpRequest and executes it. In most cases, it works great, but in other cases, it is inexplicable. What gives?
source share