My application depends heavily on android DownloadManager
component to download files with approximate size of 3-10 mega bytes.
when scaling up (to millions of downloads) the big picture is clear:
~50% of all downloads are failing due to ERROR_HTTP_DATA_ERROR.
I'm getting this info from google analytics
according to the documentation, this error code stands for:
Value of COLUMN_REASON when an error receiving or processing data occurred at the HTTP level.
I found this documentation not very informative.
there are plenty of http errors out there.
and what about network disconnection in the middle of the download? does it also triggers the ERROR_HTTP_DATA_ERROR
error after failing all the download's manager retry attempts?
It would be great if someone could help me to understand:
DownloadManager
more information about the exact http error?ERROR_HTTP_DATA_ERROR
can be fired by download manager?another point that worth mentioning: while this errors accruing - the user is connected to WIFI network (I'm setting download manager to download only over wifi)
please don't suggest me not to use download manager at all. I know about this option, advantages and disadvantages. I'm saving this option as a last resort.
Looking at the Source of DownloadManager ERROR_HTTP_DATA_ERROR
is returned by a method getErrorCode(int)
this is the exact line:
case Downloads.Impl.STATUS_HTTP_DATA_ERROR:
return ERROR_HTTP_DATA_ERROR;
android.provider.Downloads
has statuses which are masked here with DownloadManager
class's own constants, in its source:
public static final int STATUS_HTTP_DATA_ERROR = 495;
Now you got to find out what causes HTTP error 495
. After Googling a bit I came to find out that this error response code is Google related only and is often produced when downloading apps from the playstore.
A fix suggested to Go to Settings - Apps- All- Download manager and Clear data.
So in conclusion of my limited research, I think its an underlying DownloadManager
implementation related problem rather then some network or server problem, and since no definite solution/workaround is available (my friends also faced a similar situation) you should try other alternatives.