Reachability Class not working properly for VPN connection
Asked Answered
S

1

7

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;
}
Sabbatical answered 11/7, 2012 at 8:32 Comment(4)
Did you get the solution for this problem ? Please do let me know.Elvaelvah
Did you get solution for this? Same kind of issue facing in iOS9Involved
@GopeshGupta - If i remember it correctly, i assigned objReach to nil each time before checking for the host reachability. See if that works for you. I am no longer in the same organisation to cross verify the solution :(Sabbatical
Thanks @Gandalf. Followed as you suggested. But not workingInvolved
P
1

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:

  1. Connected VPN on 3G, with on demand disabled, using NetworkExtension framework.
  2. Switched to WiFi Network.
  3. Plugged off the ethernet cable from WiFI router, so router can’t share Internet.
  4. Checked if there’s Internet on the device with active VPN.

And it was there. This means , that all traffic comes through the cellular network.

Privation answered 30/5, 2016 at 14:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.