Skip to content

turn: stop refreshing after the server answers 437 to a Refresh - #962

Open
codelluis wants to merge 1 commit into
webrtc-rs:v0.17.xfrom
codelluis:turn-allocation-lost
Open

codelluis wants to merge 1 commit into
webrtc-rs:v0.17.xfrom
codelluis:turn-allocation-lost

Conversation

@codelluis

Copy link
Copy Markdown

Problem

RelayConnInternal::refresh_allocation returns Ok(()) for every error
response except 438 (Stale Nonce). When the server no longer holds the
client's allocation, for example after a NAT changes the client's port, it
answers Refresh with 437 (Allocation Mismatch). The client ignores it and
keeps refreshing: a Refresh every half lifetime and a CreatePermission
every 120 s, each one failing.

We saw this against coturn: the client logged fail to refresh permissions every 120 s for the rest of the session, and
refresh allocation failed never appeared.

Changes

  • refresh_allocation returns the error response instead of Ok(()),
    and the warning in on_timeout includes it.
  • On 437 the allocation is marked lost, and both refresh timers stop
    sending requests.

Test

test_relay_conn_allocation_lost: with the crate's TURN server and
client, allocate, delete the allocation on the server, run the allocation
refresh, and check the allocation is marked lost.

refresh_allocation returned Ok(()) on every error response except 438,
so a client whose allocation was gone on the server (437 Allocation
Mismatch) never noticed, and kept sending Refresh and CreatePermission
requests that could only fail.

Return the error instead, and on 437 mark the allocation lost so both
refresh timers stop sending requests.
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