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.
Reset content and setting of your iOS simulator, Recompile and run the app on iOS Simulator
I was having the same error message using Xcode 6.2 and running a map app (I could not load the map), resetting the simulator etc did not solve the problem, however I turned off the anti virus and web threat detector and the map loaded immediately with no error message. I then turned the anti virus and web threat detector back on and the app worked OK on the simulator and loaded the map, the error message still came up though but after 2 error messages the map loaded so it seems that the antivirus and web threat detector were treating the simulator internet connection request as a threat.
Restarting the simulator and Clear & Build, fixed the issue for me.
Try to make Your requests synchronously (one after one)