Android: TCP connection drop when disabling WiFi
stefan at agner.ch
Thu Jul 5 00:04:51 CEST 2018
On 04.07.2018 23:13, Jason A. Donenfeld wrote:
> Hi Stefan,
> I wish this were the case too, but Android sends SOCK_DESTROY to
> everything when networks change, and there isn't a lot that can be
> done about it without rooting the device, as far as I can tell. If
> you've got some Android chops and can think of a way we can suppress
> that, I'd be very interested.
Ugh, so as I expected :-(
Unfortunately, I am not very familiar with Android.
It seems that Android only kills connection when addresses get removed.
The data connection stays on in background, so that is why 4G -> WiFi
works: No addresses get removed.
Same behavior when using "Always-on VPN" or "Block connections without
VPN". It really seems a silly behavior in the light of VPNs.
With SOCK_DESTROY I pretty quickly found netd and the code which
actually causes the connection drop. It seems to me that only
connections with an address which actually gets removed get dropped
NetlinkHandler::onEvent), but maybe I don't understand the full picture.
And after some more digging I found this commit with the promising title
"Do not destroy socket when VPN interface address is still in use":
However, it seems to me that this is not relly applicable in the
More information about the WireGuard