SDWebImage - how to extend download timeout

4.4k views Asked by At

I'm using SDWebImage in my application and it works great on WiFi and 'good' 3G connections. However under slow network connections (e.g. poor 3G) it always fails downloading images because it looks like there's a 10 second timeout limit.

Can I extend such timeout so that the download can take longer before failing?

I could not find any 'timeout' property on the SDWebImage headers and I just found some hardcoded values such as

NSMutableURLRequest *request = [NSMutableURLRequest.alloc initWithURL:url cachePolicy:(options & SDWebImageDownloaderUseNSURLCache ? NSURLRequestUseProtocolCachePolicy : NSURLRequestReloadIgnoringLocalCacheData) timeoutInterval:15];

Before I used SDWebImage my low-end users were able to download images successfully (just by waiting a bit more), now the download always fails. (I'm using 'http://mschrag.github.io' to simulate slow network conditions)

3

There are 3 answers

0
hsoi On

I submitted a change that added a downloadTimeout property to the SDWebImageDownloader class. See pull request #591. And it looks like, as of this writing, that the pull request was accepted and merged into 'master'. Hopefully that solves things for you.

0
Ahmed Awan On

check it

SDWebImageManager *manager  = [SDWebImageManager sharedManager];
manager.imageDownloader.downloadTimeout = 60.0;

And add options

SDWebImageRetryFailed
2
Harshil Kotecha On

here is a solution for swift developer

SDWebImageDownloader.shared.config.downloadTimeout = 300