I have this code:
AFHTTPSessionManager *manager = [AFHTTPSessionManager manager];
NSDictionary *parameters = @{@"client_id": some index};
[manager GET:@"some address"
parameters:parameters
progress:^(NSProgress * _Nonnull progress) {
NSLog(@"In progress: %d%%", (int)([progress fractionCompleted] * 100 ));
}
success:^(NSURLSessionTask *task, id responseObject) {
[self processData:[responseObject objectForKey:@"orders"]];
}
failure:^(NSURLSessionDataTask * _Nullable task, NSError * _Nonnull error) {
NSLog(@"%@", error);
}];
It is called from viewDidLoad
. Mostly it works well, but at times I get this error:
Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: gateway timed out (504)" UserInfo={NSUnderlyingError=0x7fdd40c18aa0 {Error Domain=com.alamofire.error.serialization.response Code=-1016 "Request failed: unacceptable content-type: text/html" ...etc, nothing interesting...
However, at the console I see "In progress: 100%". In addition, in a browser I always get all the data. Hence, I propose, it is a problem of my code. How can I solve this?