How to reestablish XPC connection if my Network Extension terminates

Hi im making a LaunchDaemon app that has a NetworkExtension. I built the Network Extension using the SimpleFirewall sample project provided by apple.
My problem is that sometimes the extension terminates and when it starts again it can't communicate with the main app.
I tried setting a repeating Timer on the main app that calls a function from IPCConnection to register with the provider but that doesn't seem to work.
How should i handle this scenario.
After opening a TSI I decided to refactor my code and avoid using XPC given that it was not the best option for what I wanted to do. I wanted to send data from the Extension to the App and then have the App send that data to an api but it is best to have the Extension make the requests so it doesn't depend on the App.

Hi im making a LaunchDaemon app that has a NetworkExtension.

Why do you need to create a LaunchDaemon that has a Network System Extension? What about the Network System Extension as is does not work for your architecture?

Or did you mean that you are creating a LaunchDaemon that works along side your Network System Extension?

My problem is that sometimes the extension terminates and when it starts again it can't communicate with the main app.

I realize that SimpleFirewall does this for demonstration purposes, but what is the reason you need to communicate with the main app in your Network System Extension?


Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com

Or did you mean that you are creating a LaunchDaemon that works along side your Network System Extension?

Yeah that is what i meant, sorry.

Basically what the extension does is collect data about the outbound flow generated by unsigned apps and when it stores a certain amount it sends them to the main app which then sends them to an api. Thats all the communication that happens between the app and the extension.

Does anyone have an example code I could see to help me figure this out?
Is it possible that I need to reverse things and set up the xpc listener on the app and connect from the extension?
I think what is described in this post is exactly what im looking for. Unfortunately i can't figure out how to implement it so i will open a TSI.
Accepted Answer
After opening a TSI I decided to refactor my code and avoid using XPC given that it was not the best option for what I wanted to do. I wanted to send data from the Extension to the App and then have the App send that data to an api but it is best to have the Extension make the requests so it doesn't depend on the App.
How to reestablish XPC connection if my Network Extension terminates
 
 
Q