-
Notifications
You must be signed in to change notification settings - Fork 223
NESMVPNSession disconnected #200
Comments
Hi @miac-dev, It is hard to say what's wrong without more details. Try checking project configuration, identifiers, entitlements, provision profiles, etc. |
Hi,
Attached code This is my .entitlement and my .plist Can see this link |
Hi @miac-dev, did you resolved this problem ? |
Yes, I created a new network target in my project and added all my configuration and connection to my VPN in this target. I also added as dependencies SystemConfiguration.framework and UIKit.framework, plus NetworkExtension.framework and the OpenVPNAdapter library. |
@miac-dev, wow, can you give a code snippet where you perform NETunnelProviderManager initialization and vpn connection? |
This is my NETunnelProviderManager initialization and vpn connection. This parameter tunnelProtocol.providerBundleIdentifier = "com.app.ios.OpenVPN" [ConnectVPN.txt] (https://github.com/ss-abramchuk/OpenVPNAdapter/files/6067954/ConnectVPN.txt) |
Many thanks ! |
The same that appears in the Readme.md of this project |
Yeah, I understood, thank you very much, today I will try your solution) |
And, you have to add this parameters:
in info.plist in your new Network target. |
I tried it again, but it still didn't work.
|
I'm using the same version of xcode |
Oh, I managed to do it in a swift project ! @miac-dev, thank you for your help ! |
hi @miac-dev can share me any code related to configuration. I have a complete server setup ready with .ovpn file but I am stuck there. I have follow of your code step by step but my connection is not establish successfully. please help me I am very thankful to you. |
Hi @zubairahmad2, my problem was the following: { |
- (void) initManagerWithConfiguration:(VPNConfiguration*)config
completion:(nullable void(^)(NSError* _Nullable error))completion
{
__weak typeof(self) weak = self;
[NETunnelProviderManager loadAllFromPreferencesWithCompletionHandler:^(NSArray<NETunnelProviderManager*>* _Nullable managers, NSError* _Nullable error) {
if (error) { if (completion)completion(error); return; }
if (managers.count > 1) {
[weak uninstallAllConfigurationFromManagers:^(NSError * _Nullable error) {
weak.providerManager = managers.firstObject ? managers.firstObject : [NETunnelProviderManager new];
[weak.providerManager loadFromPreferencesWithCompletionHandler:^(NSError * _Nullable error) {
if (error) { if (completion)completion(error); return; }
NETunnelProviderProtocol *tunnelProtocol = [weak providerProtocolFromConfiguration:config];
weak.providerManager.protocolConfiguration = tunnelProtocol;
weak.providerManager.localizedDescription = @"MySuperVPN";
weak.providerManager.enabled = YES;
weak.providerManager.onDemandEnabled = NO;
[weak.providerManager saveToPreferencesWithCompletionHandler:^(NSError *error) {
NSLog(@"%@", (error) ? @"Saved with error" : @"Save successfully");
if (completion) completion(error);
}];
}];
}];
}else{
weak.providerManager = managers.firstObject ? managers.firstObject : [NETunnelProviderManager new];
[weak.providerManager loadFromPreferencesWithCompletionHandler:^(NSError * _Nullable error) {
if (error) { if (completion)completion(error); return; }
NETunnelProviderProtocol *tunnelProtocol = [weak providerProtocolFromConfiguration:config];
weak.providerManager.protocolConfiguration = tunnelProtocol;
weak.providerManager.localizedDescription = @"MySuperVPN";
weak.providerManager.enabled = YES;
weak.providerManager.onDemandEnabled = NO;
[weak.providerManager saveToPreferencesWithCompletionHandler:^(NSError *error) {
NSLog(@"%@", (error) ? @"Saved with error" : @"Save successfully");
if (completion) completion(error);
}];
}];
}
}];
}
- (NETunnelProviderProtocol*) providerProtocolFromConfiguration:(VPNConfiguration*)configuration
{
NETunnelProviderProtocol *tunel = [[NETunnelProviderProtocol alloc] init];
// 1) 'serverAddress' выглядит так: 11.111.11.111 22222
// Be sure to capture the numbers after the space !
tunel.serverAddress = configuration.remoteIP;
tunel.providerBundleIdentifier = @"mySite.com.MYAPPName.iOSPacketTunnel";
tunel.providerConfiguration = @{ @"ovpn" : configuration.configData };
tunel.disconnectOnSleep = NO;
return tunel;
} |
Hi,
I have a problem with my OpenVPN connection on my app with iOS 14.4.
I perform my VPN configuration from an oven file, with a NETunnelProviderManager protocol, but when I perform the startVPNTunnel, it starts connecting and immediately disconnects. The error I see in the logs is the following:
NESMVPNSession[Primary Tunnel:OpenVPN Client: -----(null)]: status changed to disconnected, last stop reason Plugin was disabled
This happens to me when running my app on a physical iPad.
Regards
The text was updated successfully, but these errors were encountered: