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] - Auto tunnelling does not switch on the tunnel #127

Closed
etofi opened this issue Feb 27, 2024 · 43 comments · Fixed by #298
Closed

[BUG] - Auto tunnelling does not switch on the tunnel #127

etofi opened this issue Feb 27, 2024 · 43 comments · Fixed by #298
Assignees
Labels
bug Something isn't working

Comments

@etofi
Copy link

etofi commented Feb 27, 2024

Describe the bug
When I leave my house and the trusted WiFi, Auto Tunnelling does not switch the tunnel on. Only when I open the app.
I have set everything correctly, allowed permanent location access and switched off battery optimisation.

Smartphone (please complete the following information):

  • Device: Motorola Edge 20
  • Android Version: Android 13
  • App Version 3.3.5

To Reproduce
Steps to reproduce the behavior:

  1. Leave trusted WIFI

Expected behavior
Auto tunnelling should switch on the tunnel when you leave the trusted WiFi even without having to open the app.

Screenshots (Only if necessary)

Additional context

@etofi etofi added the bug Something isn't working label Feb 27, 2024
@zaneschepke
Copy link
Owner

zaneschepke commented Mar 1, 2024

Hello! Do you have tunnel on mobile data enabled?

@etofi
Copy link
Author

etofi commented Mar 1, 2024

Yes
Screenshot_20240301-063024

@zaneschepke
Copy link
Owner

Thank you for the screenshot! A few more follow up questions..

Does this happen every time you close the app or just sometimes?

Is the auto tunnel service in paused state on the main screen?

Could you try starting auto tunneling, closing the app, turning off your wifi on your phone, and then see if it auto tunnels?

Basically, I am trying to determine if this failure only happens after the auto tunnel service has been running for a while (maybe the system killed it) or if it happens consistently every time you test.

@etofi
Copy link
Author

etofi commented Mar 3, 2024

Does this happen every time you close the app or just sometimes?

Just sometimes.

Is the auto tunnel service in paused state on the main screen?

State is active

Could you try starting auto tunneling, closing the app, turning off your wifi on your phone, and then see if it auto tunnels?

In the moment it works. But sometimes not. I can not reproduce it.

Basically, I am trying to determine if this failure only happens after the auto tunnel service has been running for a while (maybe the system killed it) or if it happens consistently every time you test.

I think it is a "run for a while" problem

@etofi
Copy link
Author

etofi commented Mar 3, 2024

Screenshot_20240303-163111
So today is the day again. The tunnel is not switched on even though I've been travelling for over 3 hours now...
Status is active.
The tunnel is activated immediately when the app is opened

@slubman
Copy link

slubman commented Mar 15, 2024

I have the same issue using the Play store version, with a Pixel 8.

The auto-tunnel will not connect the tunnel when I disconnecte from wifi or when I leave wifi coverage.
If I open the application the connection is established quickly. And the auto-connection also works for some time after that.

Is there a way to enable some logging to understand what is going on ?

@zaneschepke
Copy link
Owner

I have the same issue using the Play store version, with a Pixel 8.

The auto-tunnel will not connect the tunnel when I disconnecte from wifi or when I leave wifi coverage. If I open the application the connection is established quickly. And the auto-connection also works for some time after that.

Is there a way to enable some logging to understand what is going on ?

Hello! Thank you for the additional info. I'm sorry for the delay. I should have a fix out for this soon. Additionally, the next version of the app I am adding a logs screen to view the logs.

@etofi
Copy link
Author

etofi commented Mar 19, 2024

I have seen that 3.3.9 is now available.
When will it be available in F-Droid?

@zaneschepke
Copy link
Owner

I have seen that 3.3.9 is now available. When will it be available in F-Droid?

Hey! It usually takes about a week, but there are currently some issues with Fdroid pipeline because I have a lib that is still in process of getting published to maven central. It is currently hosted on my own package repository, but fdroid doesn't support this. Current issues for this is #47

@licaon-kter
Copy link
Contributor

F-Droid is currently upgrading to Debian Bookworm which has Java 17 installed by default.

It will take a cycle or two, so breakage is expected until done.

zaneschepke added a commit that referenced this issue Mar 30, 2024
Added tunnel settings feature where users can configure a tunnel to be used on certain SSID or with mobile data.
Closes #50

Added feature where if a tunnel was active when phone restarted, the app will start that tunnel on boot.

Removed automatic auto-tunnel toggling/override from the tunnel tile and app shortcuts as it can cause undesirable behavior.

Added second tile to control auto-tunneling pause/resume state from a tile.

Added two additional static shortcuts to be able to control auto-tunneling pause/resume state from shortcuts.

Fixed bug where crashes can happen from serializing and deserializing tunnel configs by removing the need for serialization of tunnel configs.

Refactored logic of watcher and tunnel service to make state more predictable.
#127

Fixed bug where rapidly toggling tunnels can cause crashes.
Closes #145

Improved how tunnels are manually toggled from one to another.

Improved logic/storage around primary tunnel behavior.

Fixes issue where info level logs were not populating on release builds.

Increase allowed name length displayed in UI.
Closes #143

Fixes bug where androidTV could crash in certain situations.

Bump versions.

Updated screenshots.
@kiekerjan
Copy link

I'm seeing the same issue. The tunnel is not always automatically enabled on entering untrusted wifi or mobile data. For me too it seems like a "run for a while" problem. When I start the WG tunnel app, it immediately enables the tunnel.
I have set battery usage to "unlimited" (as opposed to "optimised" or "reduced")
I'm on the 3.4.2 version from the play store.
I don't think the logs will be helpful, as when I look at "read the logs" they only go back to after I started the app, so don't show the time period in which autotunnel did not trigger.

@zaneschepke
Copy link
Owner

I'm seeing the same issue. The tunnel is not always automatically enabled on entering untrusted wifi or mobile data. For me too it seems like a "run for a while" problem. When I start the WG tunnel app, it immediately enables the tunnel. I have set battery usage to "unlimited" (as opposed to "optimised" or "reduced") I'm on the 3.4.2 version from the play store. I don't think the logs will be helpful, as when I look at "read the logs" they only go back to after I started the app, so don't show the time period in which autotunnel did not trigger.

I'll keep investigating. This is a very hard one to troubleshoot.

Do you know if the auto tunneling notification was still visible when you noticed this issue or was it closed?

Also, do you have any rough estimate on how often this occurs so I can try to replicate on a few different devices?

@kiekerjan
Copy link

I probably swiped that icon away manually. I'll keep it present and see what happens.
Rough estimate is like 1 in 3 times I leave my home (where the trusted wifi is)

@kiekerjan
Copy link

So it just happened once more. The icon reporting "monitoring network state changes: active" was still present. When I clicked it, the WG tunnel UI was opened and it resumed auto tunneling.
The logging went only back to the moment when I opened the UI.

@slubman
Copy link

slubman commented Apr 24, 2024

So it just happened once more. The icon reporting "monitoring network state changes: active" was still present. When I clicked it, the WG tunnel UI was opened and it resumed auto tunneling. The logging went only back to the moment when I opened the UI.

I got exactely the same, auto-tunnel did not activate, when opening the application immediatly re-established the connection, the log only start from when I opened the application, despite the notification being shown.

@genomez
Copy link

genomez commented Apr 24, 2024

So it just happened once more. The icon reporting "monitoring network state changes: active" was still present. When I clicked it, the WG tunnel UI was opened and it resumed auto tunneling. The logging went only back to the moment when I opened the UI.

I got exactely the same, auto-tunnel did not activate, when opening the application immediatly re-established the connection, the log only start from when I opened the application, despite the notification being shown.

I'm seeing the same thing. It happened to me once yesterday and once today. The toggle indicated I was connected, but I clearly wasn't. Once I opened the app, I was immediately connected. Both times the auto tunneling notifications were visible.

Thanks for the great app!

@dkoppenh
Copy link

I have the same issue. After a time, even though the notifications are active, the tunnel doesn't start when it should.
Once, I just had to open the app for the tunnel to activate, but more recently, I had to manually stop and start the auto-tunnelling.

A point of reference is that I changed the notifications to "silent" in the Android notification settings.

@zaneschepke
Copy link
Owner

I have the same issue. After a time, even though the notifications are active, the tunnel doesn't start when it should. Once, I just had to open the app for the tunnel to activate, but more recently, I had to manually stop and start the auto-tunnelling.

A point of reference is that I changed the notifications to "silent" in the Android notification settings.

I'm still working on getting to the bottom of this one. This is a top priority.

@zaneschepke
Copy link
Owner

I made some changes to the latest release 3.4.3 that could potentially help with this issue. Please let me know if anyone notices any differences or if this issue is still persisting.

@etofi
Copy link
Author

etofi commented May 12, 2024

Unfortunately, only version 3.4.2 is available on F-Droid. The app has now been updated to 3.4.4...

@zaneschepke
Copy link
Owner

Unfortunately, only version 3.4.2 is available on F-Droid. The app has now been updated to 3.4.4...

Yeah, Fdroid build/deployment pipelines takes up to one week. If you want updates immediately, feel free to add my custom Fdroid repo to the Fdroid app.

https://github.com/zaneschepke/fdroid

@etofi
Copy link
Author

etofi commented May 13, 2024

Yeah, Fdroid build/deployment pipelines takes up to one week. If you want updates immediately, feel free to add my custom Fdroid repo to the Fdroid app.

https://github.com/zaneschepke/fdroid

In your custom Repo only version 3.4.2 is available, too via F-Droid app.

@zaneschepke
Copy link
Owner

Yeah, Fdroid build/deployment pipelines takes up to one week. If you want updates immediately, feel free to add my custom Fdroid repo to the Fdroid app.

https://github.com/zaneschepke/fdroid

In your custom Repo only version 3.4.2 is available, too via F-Droid app.

Hmm. Are you sure you have the repo added properly? I'm able to install 3.4.4 with my repo via F-droid.

@slubman
Copy link

slubman commented May 13, 2024

Hmm. Are you sure you have the repo added properly? I'm able to install 3.4.4 with my repo via F-droid.

I had to uninstall the F-Droid version to be able to install the one from the WGTunnel repository.

@kladderadeng
Copy link

I have the same issue that the Auto connect / disconnect is not doing anything for me. I installed the Store version on LineageOS, enabled "Tunnel on mobile data", enabled "Tunnel on untrusted wifi" and added my WiFi SSID. I also tried with setting a default tunnel and not (I only have one tunnel anyway).
I allowed the app to be exempt from the battery savings and allowed it access to my location data. I restarted the Smartphone, tried with the app opened, in background and closed.

My tests was always done by turning the wifi off and on and waiting a minute. Maybe I am testing wrong and wifi should be enabled, but you have to leave the wifi zone?

@zaneschepke
Copy link
Owner

I have the same issue that the Auto connect / disconnect is not doing anything for me. I installed the Store version on LineageOS, enabled "Tunnel on mobile data", enabled "Tunnel on untrusted wifi" and added my WiFi SSID. I also tried with setting a default tunnel and not (I only have one tunnel anyway). I allowed the app to be exempt from the battery savings and allowed it access to my location data. I restarted the Smartphone, tried with the app opened, in background and closed.

My tests was always done by turning the wifi off and on and waiting a minute. Maybe I am testing wrong and wifi should be enabled, but you have to leave the wifi zone?

This specific use case has a bug that I'm currently working on where it does not turn on the tunnel when switching from wifi to mobile data. I should have a fix out for this soon!

@KjartanOli
Copy link

Not sure if this belongs here or in a new issue but I'm having similar problems with auto-tunneling. In my case I want to connect to a specific tunnel when I connect to a specific WiFi network. I've added the SSID to the 'Use tunnel on wifi name' field on the settings page for the tunnel and enabled auto-tunneling but when I connect to that WiFi network nothing happens.

@zaneschepke
Copy link
Owner

Not sure if this belongs here or in a new issue but I'm having similar problems with auto-tunneling. In my case I want to connect to a specific tunnel when I connect to a specific WiFi network. I've added the SSID to the 'Use tunnel on wifi name' field on the settings page for the tunnel and enabled auto-tunneling but when I connect to that WiFi network nothing happens.

I've just released a new version 3.4.5. Could you try this on that version and see if you are getting the same behavior? Also, could you please share your phone model and version?

Please make sure you also have "tunnel on untrusted wifi" enabled on the settings screen and auto tunneling started and not in the paused state.

@KjartanOli
Copy link

Turning on 'tunnel on untrusted wifi' makes it work. The tunnel activates when connect to the WiFi network. However, I don't want to tunnel on all untrusted networks, currently this is the only network I want to tunnel on. Is that possible?

@zaneschepke
Copy link
Owner

Turning on 'tunnel on untrusted wifi' makes it work. The tunnel activates when connect to the WiFi network. However, I don't want to tunnel on all untrusted networks, currently this is the only network I want to tunnel on. Is that possible?

Not currently possible, but I have had a request for a similar feature so I'll work on adding this.

@KjartanOli
Copy link

Thank you.

@tuxArg
Copy link

tuxArg commented Jun 1, 2024

Hi, I'm seeing this same issue. Running 3.4.5
I have 2 tunnels configured, both are the same except that one of them has an extra peer.
I want to be able to autoconnect to tunnel 1 if I'm connected to SSID A. And use tunnel 2 in any other case (another wifi or mobile data).
So I added SSID A to tunnel 1.
And mobile data and default tunnel checkbox to tunnel 2.

In general tab,
I checked "untrusted wifis" (leaving blank the trusted ones), mobile data and ethernet.

When I start auto-tunnel it connects to the tunnel it should. But if network changes, it just disconnects until I open the app again and only then it autoselects the right tunnel.

And other issues:
There are 2 active notifications, are both of them neccesary? Any how I could hide them?

In my use case that I want a persistent vpn, why can't I check always on vpn?

Thanks

@zaneschepke
Copy link
Owner

Hi, I'm seeing this same issue. Running 3.4.5 I have 2 tunnels configured, both are the same except that one of them has an extra peer. I want to be able to autoconnect to tunnel 1 if I'm connected to SSID A. And use tunnel 2 in any other case (another wifi or mobile data). So I added SSID A to tunnel 1. And mobile data and default tunnel checkbox to tunnel 2.

In general tab, I checked "untrusted wifis" (leaving blank the trusted ones), mobile data and ethernet.

When I start auto-tunnel it connects to the tunnel it should. But if network changes, it just disconnects until I open the app again and only then it autoselects the right tunnel.

And other issues: There are 2 active notifications, are both of them neccesary? Any how I could hide them?

In my use case that I want a persistent vpn, why can't I check always on vpn?

Thanks

I am able to reproduce this issue. I working on releasing a fix right now.

As for the other issue: One notification is to persist the vpn service the other is for the service watching network/state changes for auto tunneling. On Android 14, these persistent notifications can be dismissed.

You can still enable AOVPN in Android setting still, that setting just doesn't allow AOVPN to control bringing up the tunnel so it does not conflict with auto tunneling.

@zaneschepke
Copy link
Owner

Hi, I'm seeing this same issue. Running 3.4.5 I have 2 tunnels configured, both are the same except that one of them has an extra peer. I want to be able to autoconnect to tunnel 1 if I'm connected to SSID A. And use tunnel 2 in any other case (another wifi or mobile data). So I added SSID A to tunnel 1. And mobile data and default tunnel checkbox to tunnel 2.

Please give this version and shot and see if it fixes the issues you are seeing.

https://github.com/zaneschepke/wgtunnel/releases/tag/3.4.6

@tuxArg
Copy link

tuxArg commented Jun 1, 2024

@zaneschepke 3.4.6 is working for me!!

Regarding the notifications, using the official wireguard client I am able to hide it if setting AOVPN. Why is it different here?

@zaneschepke
Copy link
Owner

I'll take a look. There would still need to be at least one for the auto tunnel service.

@hermetic-charm
Copy link

hermetic-charm commented Jun 12, 2024

I am having the same issue, my phone will sometimes auto-tunnel correctly but after a while it stops. If I open the app, it resumes tunneling correctly immediately. Permissions for battery/location are set correctly and notifications for monitoring are active.

As an additional note, there has been a few times where the auto-tunnel will be active even when I am connected to a trusted Wi-Fi network. Opening the app usually turns the tunnel off immediately but there have been a few times I have needed to manually stop the tunnel. I am guessing this might be the same issue, tunnel was started when I was out and then the app entered this "long running" state and didn't disconnect when I got home because it was killed in the background or something.

Phone: Pixel 8
App version: Play Store v3.4.6
Android version: 14

Edit: I also want to add I think this is something with the newer phones/android versions handling background processes. Ever since I upgraded from my Pixel 3 to a Pixel 8 I have been seeing issues like this with a few apps which need to stay alive in the background. For example, I have a 3rd party photo syncing app: even with all permissions given, notifications on, and battery optimizations etc. turned off in the settings it eventually stops working (gets put to sleep/killed I assume). For that photo app I resorted to using Tasker to automatically open and then close the app every day at 3 AM which is a really ugly solution but seems to work okay. When I was reading around about this before, it sounded like the battery optimization settings only do so much and eventually the OS will kill/sleep old processes regardless. Also had issues with the official Gmail app not sending real time notifications. Apparently the Gmail app used to have some internal flag at the system level to always keep it alive and then they changed it. I very rarely open my email app instead just using the notifications to skim the mail then swipe it away, so probably the same thing was happening there where it put the process to sleep because I was not actually opening the app.

@kiekerjan
Copy link

Just came by to mention that in the last few weeks I didn’t see the issue occuring. Difficult to prove absence of something, but it's looking good from where I'm sitting.

@hermetic-charm
Copy link

I'm still having the issue. Sitting at the dentist office right now on 5G and the VPN has not connected but is monitoring. Just opened the app right now though and it immediately switched on.

@kafisc1
Copy link

kafisc1 commented Jul 2, 2024

I'm still having the issue. Sitting at the dentist office right now on 5G and the VPN has not connected but is monitoring. Just opened the app right now though and it immediately switched on.

I can confirm this behavior when I'm at work. I will try to create some logs tomorrow.

@dkoppenh
Copy link

dkoppenh commented Jul 3, 2024

Strangely enough, I had the opposite problem today. I connected to a non trusted wifi, and the tunnel came up.

When I reconnected to my trusted wifi, the tunnel stayed up. As soon as I opened the app, it correctly disconnected the tunnel.

@kafisc1
Copy link

kafisc1 commented Jul 9, 2024

Today I was able to reproduce the issue and created logs.
I left home WiFi at 05:52 o'clock an wgtunnel connected correctly trough mobile network.
I arrived at work around 06:03 o'clock, entered the WiFi at work automatically and wgtunnel was not able to connect.
Please see attached logs for further information.
Thank you in advance
wg_tunnel_logs-1720498108.txt

I'm using the latest version 3.4.7 in Kernel Mode on P8 Pro on A14 with the latest firmware AP2A.240705.005.

@zaneschepke zaneschepke linked a pull request Aug 3, 2024 that will close this issue
@zaneschepke
Copy link
Owner

Please try this prerelease build that I'm hoping fixes this issye: https://github.com/zaneschepke/wgtunnel/releases/tag/auto-tunnel-reliability-testing

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

Successfully merging a pull request may close this issue.