Failover Class Does Not Work Properly for VPN Connection

I am working on an application that needs a VPN connection to synchronize data. I use the reachability class to check host availability.
@ Functionality: - When the application is connected to the VPN through the Junos Pulse application, data synchronization should continue, if the VPN connection is lost, it should display an Alert message. Now it works for the scenario below.
@Working scenario: - The VPN is connected initially, I completed the synchronization and then disconnected the VPN manually from Junos Pulse. Now I'm trying to sync again, this throws a warning, which is expected.
@Problem Scenarion: - I first synchronized and left the application inactive to automatically disable the VPN. Now, after the VPN transition, I'm trying to sync again. This is not due to the warning that the VPN is not there. It tries to synchronize and fails because the server is unavailable without a VPN.

I am exhausted by finding a solution on the Internet. I am inserting a piece of code here. Any suggestion is much 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; } 
+6
source share
1 answer

There seems to be a bug in iOS. When you connect a VPN via cellular (or WiFi), and then switch to WiFi (or cellular), the system does not detect this. Reachability will not send notifications because iOS still thinks you haven't switched your interface.

I managed to reproduce it as follows:

  • A connected VPN on 3G is disabled on demand using the NetworkExtension infrastructure.
  • Switched to WiFi network.
  • The Ethernet cable is disconnected from the WiFI router, so the router cannot use the Internet.
  • Checked if there is an Internet device with an active VPN on the Internet.

And that was there. This means that all traffic flows through the cellular network.

+1
source

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


All Articles