Posts

Post not yet marked as solved
11 Replies
18k Views
Hi , I have issue when starting VPN tunnel. My code load and save preference fine,Also I can see the profile that being created from my app in Setting->General->VPN. However when i try to run "self.targetManager.connection.startVPNTunnel()", it give me NEVPNErrorDomain Code=1This is my codeself.targetManager.loadFromPreferencesWithCompletionHandler { error in let newManager = NETunnelProviderManager() newManager.localizedDescription = "CustomVPN" newManager.protocolConfiguration = NETunnelProviderProtocol() newManager.protocolConfiguration?.serverAddress = "***.***.***.***" newManager.enabled = true self.targetManager = newManager self.targetManager.saveToPreferencesWithCompletionHandler{ error in //Handle error or success if (error == nil) { if self.targetManager.connection.status == .Disconnected || self.targetManager.connection.status == .Invalid { do { NSLog("Try To Connect") try self.targetManager.connection.startVPNTunnel() } catch { NSLog("Failed to start vpn: \(error)") } } else { NSLog("Try To Disconnect") self.targetManager.connection.stopVPNTunnel() } } } }Thanks in advance
Posted
by adriansy.
Last updated
.