tunnelkit
tunnelkit copied to clipboard
Tunnel dying with ping timeout on idle or device locked (Apple bug)
Reported by several users since iOS 13.
It looks like, for whatever reason, the client is able to send data to the server, but at some point in time stops reading server responses. This is confirmed by looking at the server logs, the client assumes a ping timeout whereas the server is actually active. It's just that the client is not reading (getting?) the data.
Pings fail to deliver, because when sleep state is ultimately signalled, all queue code hangs up. As a direct consequence, e.g. packets are not sent and packet handlers are not executed until the device wakes up again.
In fact, the scheduled ping block pending execution in the tunnel queue, resumes immediately on wake-up, also causing a snappy .pingTimeout
error (the ping timeout condition is checked against in the ping()
function). This all explains why the VPN doesn't actually die during sleep, but as soon as there's a wake-up. Notice the temporary "4G" popping in the status bar when turning on the device screen, indicating a prompt reconnection.
Now the problem is: why does the queue stop running on sleep?
Potential fix: try a specific DispatchQoS
, e.g. .utility
as suggested on Apple forums.
Setting an explicit QoS didn't help. Upgrading to iOS 13.3 didn't fix the issue either.
Reported bug to Apple.
Apple never responded, but I haven't experienced this with recent iOS releases. Need to re-test properly.
This seems to be happening again in iOS 14
What information do you need from the log?
This seems to be happening again in iOS 14
What information do you need from the log?
I wouldn't say "again" as this was never resolved by Apple. If you confirm it's coming from the same test case, there's nothing to add I guess.
Thanks.
The debug log says:
14:02:37 - DNS: Using servers
looks like it is doing nothing in that period between the ping and the other errors! Hope this helps.
For me this problem only happened when I used the IKEv2 protocol. I have tested it when using both the ProtonVPN app (under Settings->VPN->Personal VPN) and the manual configuration (under Settings->VPN->VPN Configurations). The OpenVPN protocol didn't have this issue.
Definitely have this issue with OpenVPN to my router.