question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ProtocolException while downloading large files.

See original GitHub issue

After fixing the OutOfMemory issue when a large file is downloaded, everything was fine.

But, suddenly found this when I tried files with size more than 40mb. It’s working fine for 15-20 MB files.

09-23 22:08:38.716 18289-18289/sample.app W/System.err: com.androidnetworking.error.ANError: com.androidnetworking.error.ANError: java.net.ProtocolException: unexpected end of stream
09-23 22:08:38.721 18289-18289/sample.app  W/System.err: Caused by: com.androidnetworking.error.ANError: java.net.ProtocolException: unexpected end of stream

Can’t understand what’s happening.

The File was, THIS [Exe/45mb]

[EDIT] Later I’ve got some more :

Non-fatal Exception: com.androidnetworking.error.ANError: java.net.ProtocolException: unexpected end of stream
       at com.androidnetworking.internal.InternalNetworking.performDownloadRequest(InternalNetworking.java:210)
       at com.androidnetworking.internal.InternalRunnable.executeDownloadRequest(InternalRunnable.java:102)
       at com.androidnetworking.internal.InternalRunnable.run(InternalRunnable.java:57)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
       at com.androidnetworking.core.PriorityThreadFactory$1.run(PriorityThreadFactory.java:47)
       at java.lang.Thread.run(Thread.java:848)
Caused by java.net.ProtocolException: unexpected end of stream
       at okhttp3.internal.http1.Http1Codec$FixedLengthSource.read(Http1Codec.java:387)
       at okio.RealBufferedSource.read(RealBufferedSource.java:45)
       at okio.ForwardingSource.read(ForwardingSource.java:35)
       at com.androidnetworking.internal.ResponseProgressBody$1.read(ResponseProgressBody.java:76)
       at okio.RealBufferedSource$1.read(RealBufferedSource.java:409)
       at java.io.InputStream.read(InputStream.java:162)
       at com.androidnetworking.utils.Utils.saveFile(Utils.java:188)
       at com.androidnetworking.internal.InternalNetworking.performDownloadRequest(InternalNetworking.java:185)
       at com.androidnetworking.internal.InternalRunnable.executeDownloadRequest(InternalRunnable.java:102)
       at com.androidnetworking.internal.InternalRunnable.run(InternalRunnable.java:57)
       at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:422)
       at java.util.concurrent.FutureTask.run(FutureTask.java:237)
       at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
       at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
       at com.androidnetworking.core.PriorityThreadFactory$1.run(PriorityThreadFactory.java:47)
       at java.lang.Thread.run(Thread.java:848)

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:7 (3 by maintainers)

github_iconTop GitHub Comments

2reactions
amitshekhariitbhucommented, Sep 24, 2017

once disable the logging and try it out.

1reaction
sazibislamcommented, Mar 30, 2019

Just comment out the bellow code or off the debug. It works for me

//if (BuildConfig.DEBUG) { // AndroidNetworking.enableLogging(HttpLoggingInterceptor.Level.BODY) // }/

Read more comments on GitHub >

github_iconTop Results From Across the Web

Android:"Unexpected end of stream" exception downloading ...
For large files you need to set the connection time out manually by using the following code. I have set the ...
Read more >
Large file upload failure for Web application calling WCF service
The WCF service is used for uploading/downloading files to and from a server. For files, less than 50 KB upload/download works. However -...
Read more >
Retrofit 2 — How to Download Files from Server - Future Studio
This can be especially helpful when downloading files, ... If you're downloading a large file, Retrofit would try to move the entire file ......
Read more >
ProtocolException: unexpected end of stream while ...
Using a library which uses okhttp to download files, I am usually getting an unexpected end of stream error while downloading large files...
Read more >
File Download from UCM to OBIA is failing - My Oracle Support
exception.SnpsSimpleMessageException: ODI-17517: Error during task interpretation. Task: 7 java.lang.Exception: The application script threw an ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found