Search code examples
iosnetwork-programmingreachability

Host timing out in Terminal and showing as connected in reachability iOS


Today, I was testing the reachabilityWithHostName, and I'm typing a domain that is timing out inside the network that I'm joined, but the reachability its returning as its there a connection.

Why is might this be occurring?

Thanks

Here is my ping log:

PING 188.121.62.144 (188.121.62.144): 56 data bytes
Request timeout for icmp_seq 0
Request timeout for icmp_seq 1
Request timeout for icmp_seq 2
Request timeout for icmp_seq 3
Request timeout for icmp_seq 4
Request timeout for icmp_seq 5
Request timeout for icmp_seq 6

Here is my code:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // Override point for customization after application launch.

    Reachability* reachability = [Reachability reachabilityWithHostName:@"188.121.62.144"];
    NetworkStatus remoteHostStatus = [reachability currentReachabilityStatus];

    if(remoteHostStatus == NotReachable)
    {
        isInternet = NO;
    }
    else if (remoteHostStatus == ReachableViaWWAN)
    {
        isInternet = TRUE;
    }
    else if (remoteHostStatus == ReachableViaWiFi)
    {
        isInternet = TRUE;

    }

    if (!isInternet)
    {
        NSLog(@"No connection");
    }
    else
    {
        NSLog(@"There is connection");
    }

    return YES;

}

Solution

  • Can you try to ping with the below modified code .

    Reachability* reachability = [Reachability reachabilityWithHostName:@"http://188.121.62.144"];