zerotier / ZeroTierOne

A Smart Ethernet Switch for Earth
https://zerotier.com
Other
14.47k stars 1.69k forks source link

Android App Disconnects on Sleep #1130

Closed Phyxius closed 4 years ago

Phyxius commented 4 years ago

Describe the bug The ZeroTier android app disconnects when the device goes to sleep, and doesn't reconnect unless manually toggled on again. Using the "always on" VPN feature in the (system) VPN settings does not fix this; you get an error notification from the system that the VPN was disconnected instead.

To Reproduce Steps to reproduce the behavior:

  1. Join a network and toggle the network connection on in the app.
  2. Let the phone go to sleep.
  3. Wait a bit (usually less than 5 minutes on my device).
  4. See the 'key' icon disappear from the notification tray, indicating the VPN is disconnected.

This issue occurs even if the app is excluded from battery management in the system settings.

Expected behavior The VPN should stay connected and/or automatically reconnect (as with #929) when disconnected.

Smartphone (please complete the following information):

Additional context This is likely related to Android/Samsung's battery management. Apps that do not show a foreground notification (VPN services included) get aggressively killed by the system when not in the foreground and/or the system is asleep (even if they are marked as excluded from battery optimization by the user). Showing a foreground notification while connected would likely resolve this issue.

fakuivan commented 4 years ago

I can confirm the same happens with Xiaomi devices.

nickbash11 commented 4 years ago

It has become on my ASUS and 3Q devices lately. Today I got this bug more than 10 times on both devices. Earlier I don't remember such behavior.

ZeroTier says "Unfortunately, ZeroTier One has stopped." and I have to go to enable the network again.

mjmeintjes commented 4 years ago

I have been getting the same problem recently. Got an error message about not being able to invoke a method on a null object: ndptable.stop.

Android phone, Zerotier 1.4.4-1

glimberg commented 4 years ago

1.4.6-5 is out. Should resolve your issues.

ovizii commented 4 years ago

are you guys sure the problem is fixed? I had the issue that every morning I woke up to: zerotier is disconnected. manually connecting it would keep connected until the next night. I've only ever used zerotier android app for the last 5-6 days so I am on the latest version.

can anyone confirm that their issues have been solved with this latest update?

nophead commented 3 years ago

I have just installed it on my phone. It only stays connected if the app is on the screen. Within a few seconds of another app having focus it disconnects, so it is not usable for me.

user514 commented 3 years ago

I have to activate in the app the network daily. I did't notice sleep was the culprit, but you could be right. Every morning I have to reconnect. This is not new. About a year this happens everyday. App out of battery optimization, same behaivour. I'm on v1.6.4 now on a android motorola-E5.

jfiger commented 3 years ago

same issue with a Oneplus 8 / android 11

joshpetit commented 2 years ago

For me it doesn't even need to sleep in order to disconnect, it'll just disconnect randomly :sweat_smile:. This happens a few times a day and it takes me a few minutes to realize the reason why flutter stopped reloading is cause I lost connection to the device.

jfiger commented 2 years ago

Issue now solved withe the new parameter in settings->WiFi->VPN

ncwhale commented 2 years ago

Still got this problem on my Pixel 5. When the phone go to sleep mode, zerotier one disconnected.

Zerotier One version 1.8.9-1

  1. Connect to stable WiFi @home
  2. Always on VPN is on
  3. Battery save is off
SenorRodriguez commented 2 years ago

Issue still not resolved. Despite of data usage and power settings VPN gets disconnected regularly. However I suspect Android is the problem here. I tried Tailscale instead of ZT a had the same issue. Both work as charm on my Home Assistant instance.

joshpetit commented 2 years ago

However I suspect Android is the problem here.

You may have a point here. I no longer experience this issue, even after never updating zerotier. Could be something with Android.

dzhub commented 1 year ago

Issue came back with update to 1.10.5-3. ZeroTier on Android now unusable (works well on iPhone, macOS and Linux). No tunnel at all if connecting via mobile network, loses tunnel connection very often if using Wi-Fi, no ping packet (or any other packet) goes through the tunnel. Checked on Google Pixel 6a with Android 13 and XiaoMi 10T Pro with Android 12.

dzhub commented 1 year ago

Got it finally working at least on Googel Pixel 6a/Android 13. At first, there seemd to be no option for "Always on VPN", but when I finally found and set it, the tunnel started working. Now pings go through the tunnel and come back and smb connections work, too. On XiaoMi/Android 12 "Always on VPN" does not help if using mobile network.