Why would our system extension fail with error NEAgentErrorDomain code 2?

Most of the time we can use our network system extension (packet tunnel provider) as desired: The main app creates a new manager, saves it, loads it again (otherwise it won't have the correct config for some reason) and then start the connection bound to that manager.

But after several start/stop operations, all of a sudden it stops working. The only two error messages I see in console when trying to start a connection as described above are:

Code Block
neagent NEAgentSession: failed to create the delegate
nesessionmanager <our-main-app-id>[476]: Tearing down XPC connection due to setup error: Error Domain=NEAgentErrorDomain Code=2 "(null)"


And that's it. Since I have not found any reference for the NEAgentErrorDomain, I have no idea what error 2 is supposed to tell me. Nor do I have any idea why this is happening at all.

This can only be fixed by running systemextensionsctl reset and re-installing the system extension. Then it will work again for some time until the problem repeats.
Answered by DTS Engineer in 618474022
Error code 2 in NEAgentErrorDomain translates to “plug-in unavailable”. This describes the problem (that is, it’s raised after the system logs failed to create the delegate) so it doesn’t help you identify the underlying cause. My advice is that you trigger a sysdiagnose after seeing this error and then rummage backwards through the enclosed system log to see if you can spot anything that might indicate the cause.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
Accepted Answer
Error code 2 in NEAgentErrorDomain translates to “plug-in unavailable”. This describes the problem (that is, it’s raised after the system logs failed to create the delegate) so it doesn’t help you identify the underlying cause. My advice is that you trigger a sysdiagnose after seeing this error and then rummage backwards through the enclosed system log to see if you can spot anything that might indicate the cause.

Share and Enjoy

Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@apple.com"
This has been happening to us as well on 10.15.6. We're seeing this error after upgrading the extension, where nesessionmanager will refuse to load the new version. Killing nessessionmanager solves this problem, but it doesn't look like a good solution.
Were you able to find an underlying problem?
Why would our system extension fail with error NEAgentErrorDomain code 2?
 
 
Q