Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

kCFErrorDomainCFNetwork error -1005 AFNetworking

I have a singleton class:

+(id)sharedClient
{
static HackerNewsClient *__instance;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
    NSURL *url = [NSURL URLWithString:@"http://node-hnapi.herokuapp.com"];
    __instance = [[HackerNewsClient alloc] initWithBaseURL:url];
});

return __instance;
}

And in a controller I am calling this like so:

 [[HackerNewsClient sharedClient]GET:@"/news"
                         parameters:nil
                            success:^(NSURLSessionDataTask *task, id responseObject) {

                                NSArray *posts = [self parseEpisodeJSONData:responseObject];
                                completion(posts);
                            } failure:^(NSURLSessionDataTask *task, NSError *error) {
                                NSLog(@"ERROR: %@", error);
                            }];

The url this creates is http://node-hnapi.herokuapp.com/news which is a valid and working url. But the error message returned is

2014-07-08 08:51:15.942 hn[27435:1627947] ERROR: Error Domain=NSURLErrorDomain Code=-1005 "The operation couldn’t be completed. (NSURLErrorDomain error -1005.)" UserInfo=0x10ba2bf70 {NSErrorFailingURLStringKey=http://node-hnapi.herokuapp.com/news, NSErrorFailingURLKey=http://node-hnapi.herokuapp.com/news, _kCFStreamErrorDomainKey=1, _kCFStreamErrorCodeKey=57, NSUnderlyingError=0x10ba22ff0 "The operation couldn’t be completed. (kCFErrorDomainCFNetwork error -1005.)"}

I can't work out what would be causing this issue. Thanks

like image 959
joshuahornby10 Avatar asked Jul 08 '14 07:07

joshuahornby10


2 Answers

Look in the CFNetworkErrors header files for CFNetwork Framework.

In Xcode navigate to

ProjectName > Frameworks > CFNetwork.framework > Headers > CFNetworkErrors.h

like image 40
iCyberPaul Avatar answered Sep 28 '22 00:09

iCyberPaul


this error always appeared when the connection fails .. if your connection work fine just try to restart the iPhone simulator spicily with iPhone 6 simulator ...!

check link : NSURLConnection GET request returns -1005, "the network connection was lost"

like image 127
Saleh AlDhobaie Avatar answered Sep 28 '22 01:09

Saleh AlDhobaie