Skip to content

Revert ForceRelay default to false now that P2P issues are fixed#152

Open
MichaelUray wants to merge 1 commit intonetbirdio:mainfrom
MichaelUray:fix/force-relay-default-false
Open

Revert ForceRelay default to false now that P2P issues are fixed#152
MichaelUray wants to merge 1 commit intonetbirdio:mainfrom
MichaelUray:fix/force-relay-default-false

Conversation

@MichaelUray
Copy link
Copy Markdown

@MichaelUray MichaelUray commented Apr 6, 2026

Summary

The default for isConnectionForceRelayed was set to true in #108 as a workaround for P2P stability issues on Android. The underlying ICE issues have since been fixed (netbirdio/netbird: guard loop fix, candidate buffering, anet for Android interface discovery), so P2P connections work reliably and should be enabled by default.

This is a one-line change: getBoolean(keyForceRelayConnection, true)getBoolean(keyForceRelayConnection, false).

Checklist

  • Bug fix (reverts workaround now that root cause is fixed)
  • Documentation not needed

By submitting this pull request, I confirm that I have read and agree to the terms of the Contributor License Agreement.

Summary by CodeRabbit

  • Bug Fixes
    • Corrected the default connection relay setting to return the expected value when no preference is configured.

Related Issues

Fixes #130 — Android client defaults to force relay connection
Related netbirdio/netbird#5589 — Default Force Relay to Off
Related netbirdio/netbird#5672 — ICE Agent is not initialized yet on android app

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 6, 2026

📝 Walkthrough

Walkthrough

The Preferences.isConnectionForceRelayed() method default return value changed from true to false when the corresponding key is absent from SharedPreferences. This alters the fallback behavior for the connection force relay preference without modifying the method signature or other preference keys.

Changes

Cohort / File(s) Summary
Default Preference Value
tool/src/main/java/io/netbird/client/tool/Preferences.java
Modified isConnectionForceRelayed() method to return false instead of true as the default when the preference key is missing from SharedPreferences.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A preference so small, yet it matters at all,
From true down to false, the relay's default call,
One line hops along, making changes so strong,
In preferences bright, we got this thing right! ✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately and specifically describes the main change: reverting the ForceRelay default from true to false due to fixed P2P issues.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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 and usage tips.

Copy link
Copy Markdown
Contributor

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@netbird`:
- Line 1: The PR changes the default for keyForceRelayConnection in
Preferences.java from true to false but that file wasn't included for review;
open Preferences.java and verify the change to
getBoolean(keyForceRelayConnection, false) is intentional and consistent with
the rest of the codebase, then update any related logic or documentation that
assumes the old default (search for keyForceRelayConnection, getBoolean, and any
code paths handling forced relay behavior) to align behavior and tests with the
new default, and add or adjust unit/integration tests that assert the previous
default to reflect the new false default.

In `@tool/src/main/java/io/netbird/client/tool/Preferences.java`:
- Line 30: The test
PreferencesInstrumentedTest.shouldReturnTrueWhenConnectionForceRelayedIsNotSet
must be updated to reflect the new default in
Preferences.isConnectionForceRelayed(): change the assertion that currently
calls assertTrue(...) to
Assert.assertFalse(preferences.isConnectionForceRelayed()); so the test verifies
the new default false value returned by
Preferences.getBoolean(keyForceRelayConnection, false).
- Line 30: The change to Preferences.isConnectionForceRelayed() returns false by
default which breaks the test
shouldReturnTrueWhenConnectionForceRelayedIsNotSet; revert the default to true
or update the method to return sharedPref.getBoolean(keyForceRelayConnection,
true) so that isConnectionForceRelayed() yields true when the preference is
unset (refer to the method isConnectionForceRelayed and the key
keyForceRelayConnection).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: adc3d29a-5ebe-4800-bd49-f60d8c1080f6

📥 Commits

Reviewing files that changed from the base of the PR and between debe003 and ef5f776.

📒 Files selected for processing (2)
  • netbird
  • tool/src/main/java/io/netbird/client/tool/Preferences.java

Comment thread netbird Outdated
Comment thread tool/src/main/java/io/netbird/client/tool/Preferences.java
@MichaelUray MichaelUray force-pushed the fix/force-relay-default-false branch from ef5f776 to 206259a Compare April 13, 2026 04:27
The default was set to true in netbirdio#108 as a workaround for P2P stability
issues on Android. Now that the underlying ICE issues are fixed
(netbirdio/netbird: guard loop, candidate buffering, anet for Android),
P2P connections work reliably and should be enabled by default.
@MichaelUray MichaelUray force-pushed the fix/force-relay-default-false branch from 206259a to d4db909 Compare April 16, 2026 05:21
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.

Android client defaults to force relay connection

1 participant