OpenVPNAdapter icon indicating copy to clipboard operation
OpenVPNAdapter copied to clipboard

VPN Status returning nil

Open JubrilEdu opened this issue 6 years ago • 9 comments

When my app goes to the background and is returning to the foreground, the VPN status returns nil but the VPN icon is still showing on the screen of the device. This is how i query for status self.vpnManager.manager?.connection.status cc @ss-abramchuk

JubrilEdu avatar Sep 22 '18 04:09 JubrilEdu

@djubreel To get connection information, you should call a openVPNAdapter.connectionInformation. @ss-abramchuk But this property available only in the App Network Extension. But what if I need to pass this data to the host app? I have no idea how to reach that. Do you have solutions for that purpose?

AndriiDoroshko avatar Oct 22 '18 13:10 AndriiDoroshko

Hi @djubreel, have you tried to reload the manager using NETunnelProviderManager.loadAllFromPreferences?

Hi @AndriiDoroshko, you can use MMWormhole framework or if you don't want one more dependency in your project you can use UserDefaults initialized with custom suite name.

ss-abramchuk avatar Oct 22 '18 14:10 ss-abramchuk

@AndriiDoroshko @ss-abramchuk I noticed that after a long time maybe 10 minutes or the device is locked, when I request for the status, it gives nil but I can still see the VPN logo and the IP is that of the VPN server. Seeming like the app can't communicate with/control the VPN. Any idea what could be the cause? How can I go about fixing it?

JubrilEdu avatar Oct 30 '18 13:10 JubrilEdu

@djubreel i don't really realise your problem. But, keep in mind, If you run VPN as App Extension, it's gonna be a separate process. If your phone is locked, iOS may kill your app's process. But App Extension process still alive, that's why you can see VPN logo on the status bar. Currently i'm working on the project with using this library. So i can provide inspiration when i finished.

AndriiDoroshko avatar Oct 30 '18 13:10 AndriiDoroshko

Thanks @AndriiDoroshko

JubrilEdu avatar Oct 30 '18 15:10 JubrilEdu

Hello @AndriiDoroshko @ss-abramchuk. I tried using Wormhole and UserDefaults but couldn't get them to work. What I did was save a value in my app and then added an observer in the start method of the PackettunnelProvider. Any idea why it might not be working?

JubrilEdu avatar Nov 02 '18 13:11 JubrilEdu

@djubreel I have 1000 ideas why it doesn't work. First of all, to pass data between processes you have to use UserDefaults(suitName: "YourSuitName"), Your host app and extension app has to be in the same app group https://medium.com/ios-os-x-development/shared-user-defaults-in-ios-3f15cd2c9409. Do you use ReactiveSwift or RXSwift?

AndriiDoroshko avatar Nov 02 '18 13:11 AndriiDoroshko

Thanks, @AndriiDoroshko, I'm using neither. I'm using KVO instead and I have all that was in the article you shared. I was thinking it might have to do with where I attached the observer which was in the startTunnel method of the packettunnelprovider class.

JubrilEdu avatar Nov 02 '18 14:11 JubrilEdu

@ss-abramchuk my app can't seem to communicate with the VPN App extension after about three minutes, any idea what the cause could be? I have tried using wormhole library and user-defaults to no avail

JubrilEdu avatar Nov 06 '18 08:11 JubrilEdu