문제

I am using NSURLSessionDownloadTask to pull down a simple text file from my goDaddy server using the following code:

-(void)getTheInternetFile
//Fire up the downloadTask to pull the file down from my web server.
NSURLSessionDownloadTask *getTheFile = [session downloadTaskWithRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://www.myserver.com/utility/file.txt"]] 
completionHandler:^(NSURL *location, NSURLResponse *response, NSError *error) 
{
    if(error)
    {
        NSLog(@"Can't do what I want as we have an error %@", [error localizedDescription]);
    }
    else
    {
        NSLog(@"It worked");
    }
    }];

    [getTheInternetFile resume];
}

The problem I am having is that this works really well...sometimes. Other times I get an error message that states: "A server with the specified hostname could not be found".

As the URL is hard coded and never changes, I am at a loss to how this can even happen. Unless goDaddy is letting me down, and the server has all of a sudden become unavailable part of the time, I am at a loss. For what it's worth this just started acting this way today, so maybe it is goDaddy.

도움이 되었습니까?

해결책

So it turns out it was goDaddy's server having issues, despite their website reporting that there were none. It took 15 minutes on hold to find out that my code is fine.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top