You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[DevServer] Investigate how to use localhost first on desktop #17757
area/hot-reloadCategorizes an issue or PR as relevant to hot reloaddifficulty/tbdCategorizes an issue for which the difficulty level needs to be defined.kind/enhancementNew feature or request
Investigate how connect to localhost first to avoid many websocket errors on multi-homed devices.
Why is this needed
Connecting to localhost first would work for same-machine, then if it fails (e.g. remote development on a RPi) fallback to the rest of the known addresses.
We could also somehow prioritize addresses based on the "last known working", where the devserver could store the binding address of the last successful connection, then prioritize this one in a subsequent build. This would reduce the number of connection errors in Wasm and other targets and make "first-chance" debugging less annoying.
#17781 will make sure to prioritize the last known host. While it's not about connecting to localhost first, it will ensure to not cause lot of exception at startup.
This issue has had no activity for 120 days. It will be closed in 10 days if there is no further activity. Remove the Stale label or leave a comment to keep it open.
Two pieces have landed since the issue was opened, both in src/Uno.UI.RemoteControl/RemoteControlClient.cs:
Last-known-good endpoint priority (PR fix(devSrv): Improve dev-server reliability #17781). StartConnection reads the last endpoint that succeeded from ApplicationData.Current.LocalSettings and gives it delay = 0; all other candidates are delayed by 3000 ms. This significantly reduces the first-chance exception noise on subsequent runs (lines 390-415).
127.0.0.1 prepended on desktop/WASM (lines 270-289). For Browser/Windows/Linux/macOS, IPAddress.Loopback.ToString() is added at the head of the address list when not already present. Mobile is excluded.
What's still missing (the actual ask)
IPv6 loopback ([::1]) is never tried. Only IPv4 is prepended. On dual-stack or IPv6-leaning environments, this leaves cases uncovered.
Mobile is excluded too aggressively. Several mobile sub-cases would benefit from a same-machine loopback candidate:
Android Emulator (AVD) → 10.0.2.2 is the canonical alias for the host machine; 127.0.0.1 also works when adb reverse is set up.
Real devices → no change; the IDE-injected LAN address is the right answer.
Loopback dedup is string-exact."localhost", "127.0.0.1", "[::1]" are treated as unrelated entries, so duplicates can creep in if the IDE injects one of them, and the preferred matching at line 398 does not recognize them as equivalent (a saved 127.0.0.1 won't boost a fresh localhost injection, etc.).
Proposed direction
Use IP literals (not localhost) to avoid DNS resolution on the startup-critical path and to dodge ClientWebSocket.ConnectAsync's lack of Happy Eyeballs (passing a hostname picks one family only). Platform-specific candidate lists via #if (consistent with the rest of Uno.UI.RemoteControl):
Target
Loopback candidates prepended
WASM, Skia desktop
127.0.0.1, [::1]
iOS (Simulator only, runtime-detected)
127.0.0.1, [::1]
Android (Emulator only, runtime-detected)
10.0.2.2, 127.0.0.1
iOS / Android real devices
none
Plus a small loopback-equivalence helper so the preferred last-known-host matching treats the loopback group as one. The parallel Task.WhenAny race already in StartConnection makes adding multiple candidates effectively free.
area/hot-reloadCategorizes an issue or PR as relevant to hot reloaddifficulty/tbdCategorizes an issue for which the difficulty level needs to be defined.kind/enhancementNew feature or request
Activity
dr1rrb commentedon Aug 6, 2024
#17781 will make sure to prioritize the last known host. While it's not about connecting to localhost first, it will ensure to not cause lot of exception at startup.
github-actions commentedon May 6, 2026
This issue has had no activity for 120 days. It will be closed in 10 days if there is no further activity. Remove the Stale label or leave a comment to keep it open.
MartinZikmund commentedon May 6, 2026
@carldebilly @dr1rrb still relevant?
carldebilly commentedon May 6, 2026
To my knowledge, it has not been done yet. I'll check it.
carldebilly commentedon May 6, 2026
Status update after re-reading the code today.
What's already in place
Two pieces have landed since the issue was opened, both in
src/Uno.UI.RemoteControl/RemoteControlClient.cs:StartConnectionreads the last endpoint that succeeded fromApplicationData.Current.LocalSettingsand gives itdelay = 0; all other candidates are delayed by 3000 ms. This significantly reduces the first-chance exception noise on subsequent runs (lines 390-415).127.0.0.1prepended on desktop/WASM (lines 270-289). For Browser/Windows/Linux/macOS,IPAddress.Loopback.ToString()is added at the head of the address list when not already present. Mobile is excluded.What's still missing (the actual ask)
[::1]) is never tried. Only IPv4 is prepended. On dual-stack or IPv6-leaning environments, this leaves cases uncovered.127.0.0.1/[::1]reach the host (shared network stack).10.0.2.2is the canonical alias for the host machine;127.0.0.1also works whenadb reverseis set up."localhost","127.0.0.1","[::1]"are treated as unrelated entries, so duplicates can creep in if the IDE injects one of them, and thepreferredmatching at line 398 does not recognize them as equivalent (a saved127.0.0.1won't boost a freshlocalhostinjection, etc.).Proposed direction
Use IP literals (not
localhost) to avoid DNS resolution on the startup-critical path and to dodgeClientWebSocket.ConnectAsync's lack of Happy Eyeballs (passing a hostname picks one family only). Platform-specific candidate lists via#if(consistent with the rest ofUno.UI.RemoteControl):127.0.0.1,[::1]127.0.0.1,[::1]10.0.2.2,127.0.0.1Plus a small loopback-equivalence helper so the
preferredlast-known-host matching treats the loopback group as one. The parallelTask.WhenAnyrace already inStartConnectionmakes adding multiple candidates effectively free.Picking this up — will follow with a PR.