PacketTunnelProvider - setTunnelNetworkSettings error

When I'm trying to close the tunnel at my MacOS VPN app, I can see the error

Error Domain=NETunnelProviderErrorDomain Code=3 "The request to set/clear the tunnel network settings failed." UserInfo={NSLocalizedDescription=The request to set/clear the tunnel network settings failed.


Why does it happening? And how can I prevent it?


Edit:

In case I got stopTunnelWithReason, do I still need to try and close the tunnel? or is it already done by the system?

Replies

You should have a look at the system log; most errors like this log some details about the underlying cause. If necessary, you can enable extra logging using the instructions on the Bug Reporting > Profiles and Logs page.

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"

Those are some relevant msgs I get from the extra logging:


NESMVPNSession: Request to clear network agent from all interfaces
nesessionmanager NESMVPNSession: Removed network agent from utun2
Extension: Calling stopTunnelWithReason because: Stop command received
Extension: provider set tunnel configuration to (null)
nesessionmanager NESMVPNSession in state NESMVPNSessionStateStopping: plugin disconnecting, ignoring clear configuration request
...
...
Extension: IPC detached
Extension: Calling stop completion handler with error (null)
nesessionmanager NESMVPNSession in state NESMVPNSessionStateStopping: plugin NEVPNTunnelPlugin did detach from IPC
Extension: disposing
neagent: Handling didSetTunnelConfiguration Reply ERR Error Domain=NETunnelProviderErrorDomain Code=3 "The request to set/clear the tunnel network settings failed." UserInfo={NSLocalizedDescription=The request to set/clear the tunnel network settings failed.}
Extension:Calling completeRequest
SIOCGIFMTU failed: Device not configured
NEVirtualInterfaceAdjustReadBufferSize: interface_get_mtu failed (6), defaulting to max mtu


So is it OK to guess that after calling stopTunnelWithReason there is no need to clear the tunnel settings ?

Well, it's looks like there's no need to close the tunnel if stopTunnelWithReason had been called.Hope I'm right..