Transport error on 'xx.xx.xxx.xxx: NETWORK_RECV_ERROR
This is my code on PacketTunnelProvider.m file.
vpnAdapter = [[OpenVPNAdapter alloc] init]; vpnAdapter.delegate = self;
vpnReachability = [[OpenVPNReachability alloc] init];
NETunnelProviderProtocol *protocol = (NETunnelProviderProtocol *)self.protocolConfiguration;
NSDictionary *dict = protocol.providerConfiguration;
NSData* fileContent = [configContentString dataUsingEncoding:NSUTF8StringEncoding];
OpenVPNConfiguration *vpnConfiguration = [[OpenVPNConfiguration alloc] init];
[vpnConfiguration setFileContent:fileContent];
[vpnConfiguration setDisableClientCert:YES];
NSData *dt = vpnConfiguration.fileContent;
NSError *error = nil;
OpenVPNProperties *properties = [vpnAdapter applyConfiguration:vpnConfiguration error:&error];
if (error != nil) {
NSLog(@"properties Error");
return;
}
if (![properties autologin]) {
OpenVPNCredentials *credentials = [[OpenVPNCredentials alloc] init];
credentials.username = userName;
credentials.password = password;
NSError *err = nil;
[vpnAdapter provideCredentials:credentials error:&err];
if (err != nil) {
NSLog(@"Provider Credentials Error");
return;
}
}
[vpnReachability startTrackingWithCallback:^(OpenVPNReachabilityStatus status) {
if (status != OpenVPNReachabilityStatusNotReachable) {
[vpnAdapter reconnectAfterTimeInterval:5];
}
}];
[vpnAdapter connect];
i can see error as like this. Transport error on 'xx.xx.xxx.xxx: NETWORK_RECV_ERROR
What is missing on my side? Looking forward to see any reply.
Best Regards
Sasha
@kyivmobiledev I have the same problem. Have you solve it?
I can see [vpnConfiguration setDisableClientCert:YES]; in your code. Is that means you have config the username and password in your .ovpn file? if not ,you can try configing the ca,cert,key tls-auth key/value, and delete [vpnConfiguration setDisableClientCert:YES].
I am not sure it will work.
In my code ,I have config the ca,cert,key tls-auth key/value in .ovpn file and delete [vpnConfiguration setDisableClientCert:YES]. but it does not work and I think it maybe some missing in my .ovpn or some error in my certificate.
Finally I add "configuration.keyDirection = 1;" and it work. I think openvpnadapter may not support some key/value .
yes i solved it. problem was on config file.