Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Feature Request: Retry count #393

anthonycmain opened this Issue · 2 comments

2 participants


Until one of our devs finds the time, I was wondering if there were any plans, or anyone already has extending the library to have a retry count for connections.

I.e Im looking for a feature to retry a download 3 times if it times out/fails cause of a broken connection. Perhaps with a sleep period between attempts.

It would save me writing extra subs each time to support this feature


Thanks for your suggestion, @anthonycmain.

This is something that a few people have requested, but each each use case had surprisingly different requirements in what the behavior should be, which leads me to believe that a general solution that's useful for all relevant cases is intractable.

I'm of the opinion that request retrying is an application concern (or perhaps even something for the user to initiate); it's not all that difficult to implement yourself:

- (void)downloadFileRetryingNumberOfTimes:(NSUInteger)ntimes 
                                  success:(void (^)(id responseObject))success 
                                  failure:(void (^)(NSError *error))failure
    if (ntimes <= 0) {
        if (failure) {
            NSError *error = ...;
    } else {
        [self getPath:@"/path/to/file" parameters:nil success:^(AFHTTPRequestOperation *operation, id responseObject) {
            if (success) {
        } failure:^(AFHTTPRequestOperation *operation, NSError *error) {
            [self downloadFileRetryingNumberOfTimes:ntimes - 1 success:success failure:failure];

Or something like that—essentially just a basic recursive method. I hope that helps.

@mattt mattt closed this

Brilliant nice response will do the job fine, think I might just add an additional sleep parameter, will share here if I do so

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.