Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

DownloadManager ERROR_CANNOT_RESUME, status Failed

I am using android.app.DownloadManager to download large files - (about 700mb), on android tv - 7.1.1. So when server is giving me files with speed 1mb/s everything is fine. But when speed is 500kb/s I cannot download file. Almost half of file is loaded with status Running, after that DownloadManager giving status FAILED with reason ERROR_CANNOT_RESUME.

I was looking inside source code and found that android.provider.Downloads has STATUS_CANNOT_RESUME that is from 489 error code.

android.provider.Downloads

And no much information about what exactly happened. So provide me some suggestions If you reached same problem.

1 more time - the app is working fine if speed connection is fast.

like image 750
Anton Kogan Avatar asked Nov 08 '22 04:11

Anton Kogan


1 Answers

Strange that it seems to be speed related, never seen / experienced that before.
Do you manage the webserver yourself?
If so, ensure that the server sends a "Etag" with the header.
Etag-info: https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/ETag

I currently work on a webserver from scratch and I have tested different header scenarios with downloadmanager. It seems to throw STATUS_CANNOT_RESUME when reaching 99% and ETag is not present.

My Etag generator is a SHA1 of the file downloaded, and that seems fine for it.

like image 198
Large Avatar answered Nov 15 '22 04:11

Large