Time between retries
Hi, I would like to know if it is possible to add a timeout interval between retries? This is because I'm testing this feature and my current issue is that, if the user loses connection for longer than the default timeout, all the retries will be executed one after the other, without having any margin between them, even if there is no connection.
Is it possible to add this?
Thanks
Yep, you can customize the connection timeout or others for the OkhttpClient which used for FileDownload Engine.(Ref: https://github.com/lingochamp/FileDownloader/blob/master/demo/src/main/java/com/liulishuo/filedownloader/demo/DemoApplication.java#L42)
I think that the problem is that I tested it be closing all internet connections (mobile data and wi-fi). When I do it, the retries don't wait the timeout.
Here is the example:
05-05 05:01:22.154 23347-23347/com.myapp.pt I/FileDownloaderListener: Download retry. Retries: 1 Max retries: 5
05-05 05:01:22.165 23347-23347/com.myapp.pt I/FileDownloaderListener: Download retry. Retries: 3 Max retries: 5
05-05 05:01:22.165 23347-23347/com.myapp.pt I/FileDownloaderListener: Download retry. Retries: 3 Max retries: 5
05-05 05:01:22.173 23347-23347/com.myapp.pt I/FileDownloaderListener: Download retry. Retries: 5 Max retries: 5
05-05 05:01:22.173 23347-23347/com.myapp.pt I/FileDownloaderListener: Download retry. Retries: 5 Max retries: 5
05-05 05:01:22.174 23347-23347/com.myapp.pt I/FileDownloaderListener: Download error. Retries: 5 Message: Unable to resolve host "****.com": No address associated with hostname
Here is my init code:
FileDownloader.init(getApplicationContext(),
new FileDownloadHelper.OkHttpClientCustomMaker() { // is not has to provide.
@Override
public OkHttpClient customMake() {
// just for OkHttpClient customize.
final OkHttpClient.Builder builder = new OkHttpClient.Builder();
// you can set the connection timeout.
builder.connectTimeout(15000, TimeUnit.MILLISECONDS);
// you can set the HTTP proxy.
builder.proxy(Proxy.NO_PROXY);
// etc.
return builder.build();
}
});
Yes, If there isn't any internet connection, okHttp would throw an exception immediately.