VPN not starting

I've implemented a custom VPN app for macOS (Packet Tunnel Provider, network extension).

In my app there's a situation where the user tries to connect (vpn is starting), the server rejects the connection (vpn stops), and the user should enter some code and then the vpn will reconnect again (vpn should start again).
Most of the time this works as expected, but every now and then - the second connection (after the user entered the code) is stuck - the VPN goes into 'connecting' state, but it stays as connecting, without changing the state to connected or disconnected. The extension is not starting in this case.

I saw those logs at the Console:

failed to create the delegate
Tearing down XPC connection due to setup error: Error Domain=NEAgentErrorDomain Code=2

There are more related logs, but I think the above logs are the problematic ones.

After this issue, if I'm pressing the 'connect' button again, it will connect without a problem. So I think it's something related to the OS.

P.S - I also saw this thread, which looks very similar -
https://developer.apple.com/forums/thread/652708?login=true

Tearing down XPC connection due to setup error: Error Domain=NEAgentErrorDomain Code=2

After this issue, if I'm pressing the 'connect' button again, it will connect without a problem. So I think it's something related to the OS.

It does seems like there is an issue communicating with the Packet Tunnel provider. Do you see your provider actually getting hit and then the XPC connection is lost, or is the provider completely lost and the container app cannot communicate with the provider at all? Either way, Quinn is providing the next best step on the thread that you mentioned and that is to trigger a sysdiagnose and walk the logs backwards. If you do not find anything and this still continues to be an issue you could capture this in a bug report with your sysdiagnose.


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
VPN not starting
 
 
Q