I am working on an application which needs VPN connection for Data Synchronization. I am using reachability class to check the Host availability.
@Functionality :- When app is connected to VPN through Junos Pulse app, data synchronization should proceed if VPN connection is lost it should throw the Alert message. Now it is working for the scenario given below.
@Working scenario :- VPN is connected initially, i completed the sync and then disconnected the VPN manually from Junos Pulse. Now i am trying to sync again it is throwing alert which is expected.
@Problem Scenarion :- I completed the sync initially and left the app idle to get VPN disconnected automatically. Now after VPN gone i am trying to sync again. It does not through the alert that VPN not there. It attempts the sync functionality and fails as server is not accessible without VPN.
I am exhausted by searching it's solution on internet. I am pasting my Code snippet here. Any suggestion is highly appreciated.
-(BOOL)checkHostAvailability
{
Reachability *objReach = [Reachability reachabilityWithHostName:[self hostServer]];
NetworkStatus hostAvailability = [objReach currentReachabilityStatus];
if(hostAvailability == ReachableViaWiFi || hostAvailability == ReachableViaWWAN) {
RLog(@"Host is Reachable");
return YES;
}
return NO;
}
It seems like there's a bug in iOS. When you connect VPN using cellular connection(or WiFi) and then switch to WiFi(or cellular), the system doesn't detect this. Reachability won't post any notification because iOS still thinks you haven't switched your interface.
I managed to reproduce it, in the following way:
And it was there. This means , that all traffic comes through the cellular network.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With