OpenVPNAdapter icon indicating copy to clipboard operation
OpenVPNAdapter copied to clipboard

Transport error on 'xx.xx.xxx.xxx: NETWORK_RECV_ERROR

Open kyivmobiledev opened this issue 7 years ago • 2 comments

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 screen shot 2018-03-16 at 12 24 52 pm

kyivmobiledev avatar Mar 16 '18 10:03 kyivmobiledev

@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 .

february29 avatar Apr 10 '18 03:04 february29

yes i solved it. problem was on config file.

kyivmobiledev avatar May 24 '18 09:05 kyivmobiledev