netbirdio / netbird

Connect your devices into a secure WireGuard®-based overlay network with SSO, MFA and granular access controls.
https://netbird.io
BSD 3-Clause "New" or "Revised" License
10.77k stars 486 forks source link

Android-App: Netbird not reconnecting when switching between wifi and cellular #2029

Open roberthase opened 4 months ago

roberthase commented 4 months ago

Describe the problem

When switching between wifi and cellular netbird won't reconnect on android.

To Reproduce

Steps to reproduce the behavior:

  1. Connect with netbird
  2. Turn wifi off to switch to cellular
  3. Netbird keeps reconnecting without success. (dns-resolution stops working)
  4. Turn wifi back on and netbird connects successfully - or disconnect netbird and reconnect

(switching between different wifi networks works fine!)

Same issues for the other direction.

1 Connect with netbird

  1. Turn wifi on to switch from cellular
  2. Netbird keeps reconnecting without success. (dns-resolution stops working)
  3. Turn wifi off and netbird connects successfully - or disconnect netbird and reconnect

Expected behavior

Automatically reconnect on network change, which works in iOS

Are you using NetBird Cloud?

self-hosted enabled and disabled dns server in netbird controller in tests, no difference enabled and disabled private dns in android in tests, no difference

NetBird version

latest version

sisumara commented 4 months ago

I’ve been experiencing the same behavior with iOS app. When you you switch from WiFi to cellular, it doesn’t reconnect, but if you disconnect it manually and connect it on the new (Cellular) network, then it works fine, at least up to the time when signal of cellular network disappears and appears again, then the issue happens again. The same will be if you connect to the WiFi network after cellular.

I’m on the latest version of self hosted NetBird.

pascal-fischer commented 4 months ago

Hi, regarding the issue on Android, we are aware and have already merged a fix which will be released soon. For iOS I am not aware of an issue when switching networks. I will need to investigate this.

Edit: Reproduced on iOS.

roberthase commented 4 months ago

Hi there,

i grabed the new update from the playstore with the fix

"Fix the reconnection issue after the network switch"

If netbird ist connected, switching between wifi and cellular does not break dns-resolution on the device anymore.

Still, netbird does not seem to let go of the interface which handled the inital connection and requires manual reconnect or switching back to the interface used for the inital connection.

pappz commented 4 months ago

@roberthase which version did you test? Could you send to me the version number?

roberthase commented 4 months ago

OS: Android 14 Modell: SM-A546B/DS App-Version: 0.0.23 Server-Version: 0.27.9

pappz commented 4 months ago

@roberthase How looks like the DNS configuration on the Dashboard? Did you add any specific DNS settings for your Android device? Could you send logs from your Android device? You can collect logs via the "Advanced" menu in the app.

roberthase commented 4 months ago

This has to be some weird configuration on my side not related to netbird. I will report back

sisumara commented 4 months ago

Hi

it seems that after the latest IOS update it behaves properly and the only one thing is that after some hours of work the VPN connection just turns off completely and you need to reconnect it again.

Thank you for your hard work.

sisumara commented 4 months ago

@pascal-fischer it seems that the problem with IOS app is still there. Maybe it’s not a DNS problem… Sometimes it just loses the connection and hangs in that position. I have about 6 peers and it shows “Connecting” to each of those peers and after that it shows “Disconnected”, and after that again “Connecting” and it does it indefinitely, until you stop it with Dissconnect button and then reconnect it again. Something is wrong in there. So it can’t reconnect automatically after some event. Usually it happens on cellular network when you move through the base stations and it seems that the phone loses the signal sometimes and after that it just stops to work.

roberthase commented 4 months ago

To follow up on my last comment and after looking at the logs from the client:

Switching between wifi and cellular on ios and android is fine when the dns-name of netbird points to the same public ip.

In my testing setup the android client was using our internal dns when connected to wifi. The internal dns was pointing to the local ip of netbird and the public ip was not reachable from the local network

When switching from wifi to cellular, the netbird android app was still trying to connect the local ip.
I dont know if this is the expected behaviour, since i cant reproduce it on iOS.

Edit: In another test, the public ip was reachable from the local network and reconnecting was also working fine.

pascal-fischer commented 4 months ago

Hi @sisumara , @roberthase, I have not yet fixed anything in that regard on iOS so I would expect the issue to still be there. I tried a few things to re-establish the connection but without success. I will need time to look deeper into this to find out why the reconnection is failing.