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
strelaysrv: second join of a session is refused with "already connected" although the session is not full #10952
AddConnection hands the connection to Serve with a non-blocking send on an unbuffered channel (connsChan, AddConnection). If Serve is not at its receive when the second join arrives, AddConnection returns false and the listener answers ResponseAlreadyConnected, although the session is not full. findSession has already deleted the key, so the refused side cannot retry, and the accepted side waits in a half-empty session until its own timeout.
Both invitations are written one after the other, so two clients that join as soon as they have their invitation can arrive microseconds apart.
Reproduction, v1.30.0 and ed2e0fd: one client keeps a control connection, a second asks for an invitation with client.GetInvitationFromRelay, then both call client.JoinSession at the same instant (goroutines released together), 300 rounds. In several runs 6 to 25 percent of the joins were answered incorrect response code 2: already connected (for example 94, 113, 61, 144 and 149 of 600). With one side waiting 20 ms, none of 300 were.
In an application this shows as a connection attempt failing with that error or, on the accepted side, client handshake: ... i/o timeout. About one run in ten of an integration test through a local relay failed that way.
Activity
relay: the machine and the key holder join a session a few millisecon…
relay: the machine and the key holder join a session a few millisecon…