am my app made and doing POST request using the AFHTTPRequestOperationManager.
I have 4 urls which all works fine with the server, they are pretty much the same format, same usage, etc. So I coded them the same as well.In actually fact I only have an if statement to determine which url I shall use for the same method I made, so every time I request any of the urls with POST I use the same one.
For 3 of them they just work perfectly, but the 4th one, no matter how I use it, it always gets me "Domain=NSURLErrorDomain Code=-1005 "The network connection was lost."
I tested with this url on my server, it works fine. There's nothing wrong with the server, but AFNetworking just won't send this request out. If its a true DC then my other URLs are still working fine?
I run this app on IOS8 beta2, I don't know if the beta is causing the issue? (Which I doubt) pls help ...
Sample code
#define SERVER_URL @"http://54.187.63.214/"
#define SERVER_LIKE_URL @"candidate_likeJob/"
#define SERVER_DISLIKE_URL @"candidate_dislikeJob/"
- (void) likeOrSkipJob:(BOOL)isLike{
UserSetting *setting = [UserSetting getSetting];
UFCompany *matchedCompany = [matchedCompanies lastObject];
UFJob *matchJob = [matchedCompany.jobs firstObject];
NSLog(@"like job : %@", matchJob.position);
AFHTTPRequestOperationManager *manager = [[AFHTTPRequestOperationManager alloc] init];
NSString *likeURL = [NSString stringWithFormat:@"%@%@",SERVER_URL,isLike? SERVER_LIKE_URL: SERVER_DISLIKE_URL];
NSDictionary *params = [[NSDictionary alloc] initWithObjectsAndKeys: setting.ufind_id, @"candidate_id", matchJob.job_id, @"job_id", nil];
NSLog(@"Request URL: %@ with params %@", likeURL, params);
[manager POST:likeURL parameters:params success:^(AFHTTPRequestOperation *operation, NSDictionary *response) {
NSString *status = [response objectForKey:@"status"];
//if server tell status ok
if ([status isEqualToString:@"ok"]) {
NSLog(@"%@ job success", isLike? @"Like":@"Dislike");
//update the work if like succeed
[matchedCompanies removeLastObject];
[self updateMatchScreen];
}
} failure:^(AFHTTPRequestOperation *operation, NSError *error) {
NSLog(@"like request failed %@", error);
}];
}
The SERVER_LIKE_URL is generating the -1005 "connection lost", but SERVER_DISLIKE_URL always work.