AFNetworking 2.0 Acceptable Availability incorrectly reports inaccessibility - AFNetworkReachabilityStatusNotReachable

I am using the AFNetworking 2.0 accessibility feature as indicated in their sample code. I have a test server on the local LAN with which the iOS application interacts during testing. When I run the application in the simulator with WLAN, AFNetworking initially reports that the server / URL is available, but then it returns it back to inaccessible (although the server is there, it is accessible and the WLAN is working fine). This means that it disables the operation queue, so the application will not communicate with the server, although this certainly can be.

Any suggestions why AFNetworking is not correctly reporting the local server / URL as inaccessible?

Here is my code:

AFHTTPRequestOperationManager *mgr = [[AFHTTPRequestOperationManager alloc] initWithBaseURL:[NSURL URLWithString:@"http://192.168.188.20:3000/"]];
NSOperationQueue *operationQueue = self.httpManager.operationQueue;

[mgr.reachabilityManager setReachabilityStatusChangeBlock:^(AFNetworkReachabilityStatus status)
   {
        NSLog(@"Reachability for %@ has changed to %@", @"http://192.168.188.20:3000/",AFStringFromNetworkReachabilityStatus(status));


        switch (status) {
            case AFNetworkReachabilityStatusReachableViaWWAN:
            case AFNetworkReachabilityStatusReachableViaWiFi:
                NSLog(@"re-enabling operation queue");
                [operationQueue setSuspended:NO];
                break;
            case AFNetworkReachabilityStatusNotReachable:
            default:
                NSLog(@"disabling operation queue");
                [operationQueue setSuspended:YES];
                break;
        }
    }];

, : WLAN , IP- :

Jan 31 13:21:04  MyApp[10671] <Warning>: Reachability for http://192.168.188.20:3000/ has changed to Reachable via WiFi
Jan 31 13:21:04  MyApp[10671] <Warning>: re-enabling operation queue
Jan 31 13:21:04  MyApp[10671] <Warning>: Reachability for http://192.168.188.20:3000/ has changed to Not Reachable
Jan 31 13:21:04  MyApp[10671] <Warning>: disabling operation queue`

, , . .

- ? , " ", ""?

+4

Source: https://habr.com/ru/post/1525966/


All Articles