Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] - Tunnel is not adapting for a network change #562

Open
szotsaki opened this issue Jan 28, 2025 · 6 comments
Open

[BUG] - Tunnel is not adapting for a network change #562

szotsaki opened this issue Jan 28, 2025 · 6 comments
Assignees
Labels
bug Something isn't working

Comments

@szotsaki
Copy link

Describe the bug

When a network change occurs on the phone (e.g. from air plane mode to WiFi, or transitioning from WiFi to mobile), the tunnel cannot use the new network. It's a sporadic issue, but rather frequent (once or twice a week).

Smartphone (please complete the following information):

  • Device: moto g(100)
  • Android Version: 12
  • App Version: 3.6.6
  • Backend: User-space

To Reproduce

  1. Turn off "Restart on ping fail". The network change detection should be automatically handled in the moment it happens, and should not rely on pings
  2. Use your phone normally, alternating among air plane mode, WiFi, mobile data, roaming, etc.

Expected behavior
Tunnel keeps up

Additional context
"Last ping" in these cases is sometimes hours ago. As soon as I turn it off and immediately back on, the connection is restored.

Whether a tunnel restart or some other technique is needed when a change is detected, I don't know.

@szotsaki szotsaki added the bug Something isn't working label Jan 28, 2025
@jorti
Copy link

jorti commented Feb 7, 2025

I'm not sure if it's the same issue, but since I upgraded my phone to LineageOS 22.1 (Android 15) I'm always having this problem in the morning:

I've configured auto-tunnel to active the vpn anywhere except in my home wifi. It works, but after leaving the phone charging all night it stops working in the morning. If I deactivate auto-tunnel and activate it again, it keeps working until the next day. It looks like the network change monitoring is killed overnight.

I've already disabled any battery optimization for the app. Is there anything else I can do?

@jorti
Copy link

jorti commented Feb 7, 2025

Attaching log of a test today (around 07 Feb 2025 09:08 UTC) in which I first turned off the wifi and the tunnel was not activated. Then I turned auto-tunnel off and on and it activated. Tested with WG Tunnel version 3.6.6

logcat_1738891094764.txt

@popy2k14
Copy link

I am experiencing the same issue mostly over night.
Maybe the service is killed by android.
Also tried to play with the denounce delay, which did not help.

I saw @zaneschepke committed some code to overcome this.

Hope this will fix the issue.

@zaneschepke what do you mean, will our issue be solved with your commits on upcoming versions, or do you need additional logs?

@jorti
Copy link

jorti commented Feb 22, 2025

Since my previous comment I've been testing with the official Wireguard app, using the native always-on VPN and disabling all battery optimizations, but the results were the same: the app was killed in the morning and the phone had no Internet because the VPN was not active.

I've been a LineageOS user for many years and this didn't happen in the past with older Android versions, so I now believe it's a new Android 15 behaviour.

@popy2k14
Copy link

Yeah, also sometimes writing apps on Android and work every version it gets worse.

I think the only "workaround" is a monitoring service.
Which @zaneschepke had added recently (when I got it right).

@zaneschepke
Copy link
Owner

Unfortunately Google keeps making it harder and harder to make useful apps and they keep locking down features behind more permissions, more aggressive service killing, etc 😦

As for this ping issue, there are definitely some issues with the pinger logic in the current production version. I've made some improvements to this and made sure we are not using cached DNS so it will reresolve the DNS when the pinger bounced the tunnel.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

4 participants