AFNetworking的默认超时秒数?

时间:2015-09-15 09:57:05

标签: ios objective-c afnetworking nsurlconnection nsurl

在我的项目中,我使用AFNetworking进行Api调用,如何识别AFNetworking的默认超时秒数。请建议。

1 个答案:

答案 0 :(得分:13)

AFNetwork的默认超时 60秒

  

超时间隔,以秒为单位。如果在连接期间尝试了   请求保持空闲的时间超过超时间隔(请求)   被认为已超时。默认超时间隔为60   秒。

额外reference

如果你想减少超时

NSDictionary *params = @{@"par1": @"value1",
                     @"par2": @"value2"};

AFHTTPRequestOperationManager *manager = [AFHTTPRequestOperationManager manager];

[manager.requestSerializer setTimeoutInterval:25];  //Time out after 25 seconds

[manager POST:@"URL" parameters:params success:^(AFHTTPRequestOperation *operation, id responseObject) {

//Success call back bock
NSLog(@"Request completed with response: %@", responseObject);


} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
 //Failure callback block. This block may be called due to time out or any other failure reason
}];