I am trying to execute a datatask with a URLSession, when I run it on an iOS11 device (iPhone 5S), I get a console error:
2017-09-22 15:22:17.942015-0300 app[1355:283536] TIC TCP Conn Failed [3:0x1c417af40]: 1:61 Err(61) 2017-09-22 15:22:17.943698-0300 app[1355:283536] Task <A32F0275-75C3-4F64-AB92-2E37527AB813>.<0> HTTP load failed (error code: -1004 [1:61]) 2017-09-22 15:22:17.945265-0300 app[1355:283676] NSURLConnection finished with error - code -1004
Running on the simulator does not occur.
What causes this or how to fix it?
That's what I'm doing
#define kEcardURL @"https://example.com/mobile/services/ecard/" - (void)doSomething { //Params Configuration NSDictionary *parameters = [NSDictionary dictionaryWithObjectsAndKeys: [oauth.userData valueForKey:@"wsuserid"], @"token", nil]; NSString *path = @"fotoCartao"; NSData* params = [NSJSONSerialization dataWithJSONObject:parameters options:0 error:nil]; NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@%@", kEcardURL, path]]; NSMutableURLRequest *urlRequest = [NSMutableURLRequest requestWithURL:url]; [urlRequest setHTTPMethod:@"POST"]; [urlRequest setValue:@"application/json" forHTTPHeaderField:@"Content-Type"]; [urlRequest setHTTPBody:params]; NSURLSessionDataTask *dataTask = [[self session] dataTaskWithRequest:urlRequest completionHandler:^(NSData *data, NSURLResponse *response, NSError *error) { NSHTTPURLResponse *httpResponse = (NSHTTPURLResponse *)response; if ([data length] > 0 && error == nil) { if ([httpResponse statusCode] == 200) { //do stuff } } }]; [dataTask resume]; } } - (NSURLSession *)session { static dispatch_once_t onceToken; dispatch_once(&onceToken, ^{ // Session Configuration NSURLSessionConfiguration *defaultConfigObject = [NSURLSessionConfiguration defaultSessionConfiguration]; // Initialize Session _session = [NSURLSession sessionWithConfiguration: defaultConfigObject delegate: nil delegateQueue: [NSOperationQueue mainQueue]]; }); return _session; }
source share