I've implemented a VPN app with Packet Tunnel Provider, both for iOS and macOS (both apps use the same extension code, with some minor differences).
For the macOS app, I'm getting reports from users that sometimes they can't connect using the client and has to disconnect and reconnect again their network (wireless or wired) in order to connect again. From the app's logs, I can see the message "Network is unreachable".
This is not true because the users tried to ping multiple sites, and it went fine. So there is a reachable network.
More info:
They aren't at an IPv6 only environment (and anyway, my apps support IPv6).
I'm using BSD sockets.
Some users reported that when this happens, if they wait long enough ~10 min, they are able to connect again.
The iOS app has no such problems even it uses the same code.
So in order to solve it, how can I get more information? Can my app get the network information, and check the sockets state?
Can I get the system's logs and information and save it to my log file?
Is there something that might explain this behavior, like "the PacketTunnelProvider wasn't killed properly", the PacketTunnelProvider crashed and the cause networking problems?
Edit: Is it possible, that some of the following cases are the cause for the "Network is unreachable" error?
In all of those cases, the onDemand is enabled:
-The VPN disconnects and then immediately reconnect (on demands takes effect), but it does so without waiting 20 seconds, which triggers the known bug for macOS Packet Tunnel Provider
- The device enters sleep mode, but the VPN tries to connect again and again (on demands takes effect)