Hi again all, We have a weird situation here on sleep/wake in our NEPacketTunnelProvider-based app. The sleep and wake callbacks are called properly and we have noticed that the NWUDPSession is disconnected just after the Mac has awakened... if the Mac is running on an Ethernet connection? The same sleep/wake behaves properly if the Mac is running on Wifi?!? Weird. Do we need to wait for some state after wake? It's hard to understand since it's only happening when running on the Ethernet-port. Confused here 🤪. Best regards / Jorgen / Clavister AB
VPNConnection using NWUDPSession disconnecting after sleep/wake
Do we need to wait for some state after wake? It's hard to understand since it's only happening when running on the Ethernet-port.
It's hard to say. It may be just that your packet tunnel needs to reconnect itself with the VPN server and the NWUDPSession
has gone into the .failed
or .cancelled
state. What is NWUDPSessionState
reporting when this happens?
Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com
Hi again Matt,
I can see this error when trying to writeDatagram just after wake from sleep...
Failed to write data to udpSession. Error: The operation couldn’t be completed. No buffer space available, (code=55)
Best regards / Jorgen
It seems like if we keep trying the NWUDPSession eventually can start to write
Is it a situation where your packet tunnel just needs to re-establish the connection to the server in the wake
method and until it does the NWUDPSession
is not available? If this is true I am assuming that based on the successful call to setTunnelNetworkSettings
you could go through and establish the session for NWUDPSession
once again.
You may also want to check the NWUDPSessionState
in this condition and if it reports .failed
or .cancelled
it would be worth testing out whether you can establish the NWUDPSession
once again. If you cannot then I would suspect that your packet tunnel is not setup from coming alive on wake.
Matt Eaton
DTS Engineering, CoreOS
meaton3@apple.com