Closed lihengchang closed 2 years ago
When the VPN is closed, the openVPNAdapter:handleError: method returns an error :
Error Domain=me.ss-abramchuk.openvpn-adapter.error-domain Code=27 "OpenVPN error occured" UserInfo={NSLocalizedDescription=OpenVPN error occured, me.ss-abramchuk.openvpn-adapter.error-key.message=EADDRNOTAVAIL: Can't assign requested address, me.ss-abramchuk.openvpn-adapter.error-key.fatal=false, NSLocalizedFailureReason=General transport error}
In fact, when the VPN was closed, the openVPNAdapter:handleError: method called back twice
Error returned for the first time :
Error Domain=me.ss-abramchuk.openvpn-adapter.error-domain Code=27 "OpenVPN error occured" UserInfo={NSLocalizedDescription=OpenVPN error occured, me.ss-abramchuk.openvpn-adapter.error-key.message=EADDRNOTAVAIL: Can't assign requested address, me.ss-abramchuk.openvpn-adapter.error-key.fatal=false, NSLocalizedFailureReason=General transport error}
Error returned for the second time :
Error Domain=me.ss-abramchuk.openvpn-adapter.error-domain Code=20 "Failed to reset tunnel. Check underlying error for more details." UserInfo={me.ss-abramchuk.openvpn-adapter.error-key.fatal=true, NSLocalizedDescription=Failed to reset tunnel. Check underlying error for more details., NSUnderlyingError=0x10360a450 {Error Domain=NEAgentErrorDomain Code=1 "(null)"}}
When I connect to VPN (4G), I turn on Wi-Fi, and when I turn off Wi-Fi, there is no such problem
So there is a point of suspicion. The VPN connection is established during Wi-Fi, and the socket is established based on Wi-Fi. Turning off Wi-Fi at this time will cause the socket to fail.
The VPN connection is established in 4G, and the socket is established based on 4G. Switch to Wi-Fi at this time, 4G network still exists, but the priority is not as good as Wi-Fi, so the socket is active
But I can’t verify this conjecture
Issue resolved
The reason for VPN is closed has been found. Because the openVPNAdapter:handleError: method is implemented in accordance with the demo on the homepage, when an error is received, the following code is executed, resulting in VPN is closed
if (self.startHandler) {
self.startHandler(error);
}else {
[self cancelTunnelWithError:error];
}
After commenting the if, it will automatically reconnect after 5 seconds.
It is recommended that the demo code on the homepage add comments to some non-essential codes, for example:
if (self.startHandler) {
self.startHandler(error);
}else {
[self cancelTunnelWithError:error];
}
And
self.startHandler = nil;
Hi, When i connect to VPN (Wi-Fi), then close Wi-Fi, and the VPN is closed.
log is : Connected via tun Per-Key Data Limit: 48000000/48000000 LZO-ASYM init swap=0 asym=1 Comp-stub init swap=0 UDP send exception: send: Can't assign requested address Transport Error: EADDRNOTAVAIL: Can't assign requested address Client terminated, restarting in 5000 ms...
No other logs.
Thank you..