Skip to content

fix: notify Go core on seamless network handover (cellular → WiFi) while VPN is active - #243

Open
hchengting wants to merge 4 commits into
netbirdio:android-airplanefrom
hchengting:notify-new-network
Open

fix: notify Go core on seamless network handover (cellular → WiFi) while VPN is active#243
hchengting wants to merge 4 commits into
netbirdio:android-airplanefrom
hchengting:notify-new-network

Conversation

@hchengting

Copy link
Copy Markdown

When onNetworkAvailable detects a new transport type appearing alongside an already-present one (e.g. WiFi coming up while cellular is still connected), it now calls notifyListener() to forward the network-change event to the Go core.

Before: Switching from cellular to WiFi with the VPN active caused a 10–20 second outage — peer connections stayed bound to the old transport, DNS queries to peer nameservers timed out (4s each), and recovery only happened once ICE eventually detected the connection as disconnected/failed (~6s timeout × multiple retries).

After: The Go core is notified immediately, triggering the sweeper (cuts stale management/signal/relay connections) and resetting peer reconnect backoff, so peers reconnect on the new transport within ~1–2 seconds — matching the WiFi→cellular recovery time.

Related to: #146

@coderabbitai

coderabbitai Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Important

Review skipped

Auto reviews are disabled on base/target branches other than the default branch.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: c1037731-abbd-4c8b-9fe6-468526306f71

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@pappz

pappz commented Aug 18, 2026

Copy link
Copy Markdown
Collaborator

Thanks for the fix! One question: this also fires in the reverse case, e.g. cellular comes up while the device stays on WiFi. That's still a new type with size() > 1, so peers get reset even though nothing changed for the tunnel. Should we only notify when the new transport actually displaces the current one?

@hchengting

This comment was marked as outdated.

Track the highest-priority validated transport (WiFi > Cellular) and
only fire NotifyNetworkChange when it truly changes, instead of whenever
a secondary transport validates. This prevents false notifications when
enabling cellular data while WiFi is already the active network.
pappz added a commit that referenced this pull request Aug 19, 2026
Prove the engine survives every WiFi/cellular/no-network combination
without a restart, and that it recovers via the network-change fast
path: the budgets are deliberately tight, so a recovery that only
happens after ICE disconnect detection and backoff retries fails the
test. All assertions are data-plane checks (ping to a live peer, or
HTTPS egress through the exit node), not just the Connected status.

The cellular->WiFi handover speed case is expected to fail until the
community fix (#243) merges; it is ordered last so the fail-fast
listener does not skip the rest of the suite.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants