Reputation: 779
I have problem with VPN on ios. I use this code.
let result = NEOnDemandRuleConnect()
result.interfaceTypeMatch = .any
manager.onDemandRules = [result]
manager.isOnDemandEnabled = true
Sometimes, if I unlock iphone after 1-2 hours of sleep, VPN is not working. VPN icon in status bar is shown, wifi connection icon is shown, but network is not working (I can't load any page in safari). If I manually reconnect VPN in app or in system settings - it starts to work correctly. I'm using ipsec protocol.
How can I fix this problem?
Upvotes: 0
Views: 1147
Reputation: 779
We solved an issue in other way - we replaced ipsec with ikev2 and now VPN is working correctly.
Upvotes: 0
Reputation: 645
I haven't worked with IPSec protocols, but have some experience with VPNs in Network Extensions. Override the sleep and wake methods in your PacketTunnelProvider
. You should specify there how the tunnel should behave when it goes to sleep and in the wake method how to reactivate it. See this answer in Apple's forums.
You should also set disconnectOnSleep
to false
to prevent the tunnel from disconnecting when it goes to sleep (self explanatory).
Upvotes: 1