Skip to content

ice: Reset TURN auth state when failing over to next server - #447

Closed
sashakosti wants to merge 1 commit into
ValveSoftware:masterfrom
sashakosti:fix-turn-failover-credentials
Closed

sashakosti wants to merge 1 commit into
ValveSoftware:masterfrom
sashakosti:fix-turn-failover-credentials

Conversation

@sashakosti

Copy link
Copy Markdown

When a TURN allocate request times out, STUNRequestCallback_AllocateRelay attempts to fail over to the next server in m_vecTURNServers. However, m_strTURNRealm, m_strTURNNonce, and m_arrTURNKey were retained from the previous server.

This caused QueueTURNRequest to treat the new request as already challenged, immediately attaching the previous server's realm, nonce, and MD5 key. The new server would reject the request (typically with 401), causing relay discovery to fail prematurely.

Resetting m_strTURNRealm, m_strTURNNonce, and m_arrTURNKey before queueing the request on the next TURN server ensures a clean handshake adhering to RFC 5766 and restoring the documented invariant in ICESessionInterface ("m_strTURNRealm is empty until then").

Fixes #445

When a TURN allocate request times out, STUNRequestCallback_AllocateRelay
attempts to fail over to the next server in m_vecTURNServers. However,
m_strTURNRealm, m_strTURNNonce, and m_arrTURNKey were retained from the
previous server.

This caused QueueTURNRequest to immediately send an authenticated Allocate
to the new server using the previous server's realm and nonce, leading to
authentication rejection and premature relay failure.

Reset m_strTURNRealm, m_strTURNNonce, and m_arrTURNKey before queueing the
request on the next TURN server to ensure a clean handshake.

Fixes ValveSoftware#445
@sashakosti

Copy link
Copy Markdown
Author

Closing in favor of #446 which addressed this issue first.

@sashakosti sashakosti closed this Oct 11, 2026
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.

Native ICE TURN failover fails when the servers use different credentials

1 participant