Skip to content

Retry original username before falling back to an auto-incremented name - #292

Open
kb9gxk wants to merge 1 commit into
sonosaurus:mainfrom
kb9gxk:username-collision-retry
Open

Retry original username before falling back to an auto-incremented name#292
kb9gxk wants to merge 1 commit into
sonosaurus:mainfrom
kb9gxk:username-collision-retry

Conversation

@kb9gxk

@kb9gxk kb9gxk commented Aug 12, 2026

Copy link
Copy Markdown

Summary

When you reconnect after a dropped connection (network blip, app restart), you often come back into a group renamed to "Name 2" even though your original session is truly gone — not because someone else is using your name, but because the server hasn't timed out your own stale session yet.

The server's login (get_user() in deps/aoo/lib/src/server.cpp) returns a flat "access denied" for any username collision — it can't distinguish "someone else genuinely has this name" from "this is your own not-yet-expired session from a moment ago." The client currently treats every rejection as the former and immediately switches to an auto-incremented name on the very first failure.

This also compounds over time: the auto-incremented name gets saved as your new default username, so future connections start from "Name 2" already, and can creep further ("Name 3", etc.) on subsequent unlucky reconnects.

Changes

  • On "access denied," retry the original (un-suffixed) username up to 3 times (~2.5s apart, ~7.5s total) before falling back to the auto-incremented name — giving a same-device reconnect a real chance to reclaim its name once the server's stale session clears.
  • Decoupled the persisted default username from whatever name a session actually ends up connecting with: even if a session falls back to "Name 2," the original requested name is what gets remembered for next time, not the fallback.

Not included

No server-side changes. The AOO protocol has no in-session rename message, so reclaiming an already-active fallback session mid-session would require a disruptive disconnect/reconnect cycle — out of scope here; this only affects the initial-connect path.

Testing

Built clean on both Linux and Windows (MSVC) with no new warnings, against a fresh checkout of main.

Root cause: the server rejects a login with "access denied" for
any username collision -- whether a genuinely different peer holds
the name, or it's our own stale session from a recent drop/restart
that the server hasn't timed out yet. The client couldn't tell
these apart and always assumed the worst, immediately switching to
an auto-incremented name ("Name 2") on the very first rejection.

Now retries the original name up to 3 times (~2.5s apart) before
falling back to the incremented name, giving a same-device
reconnect a chance to reclaim its name once the stale session
clears server-side. Also decouples the persisted default username
from whatever name the session actually ended up connecting with,
so a fallback name doesn't compound into future sessions -- the
original requested name is always what gets remembered, even if
this particular session is running under a fallback name.

No server-side changes -- the AOO protocol has no in-session
rename message, so reclaiming an already-active fallback session
would require a disruptive disconnect/reconnect; per discussion,
scoped this to the initial-connect retry only, not background
reclaim.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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.

1 participant