Skip to content

Abort pending STUN transactions when the protocol is closed - #121

Open
jsntcheng wants to merge 1 commit into
aiortc:mainfrom
jsntcheng:fix/close-pending-transactions
Open

jsntcheng wants to merge 1 commit into
aiortc:mainfrom
jsntcheng:fix/close-pending-transactions

Conversation

@jsntcheng

Copy link
Copy Markdown

Closing a StunProtocol while a transaction is in flight leaves the transaction running: its retry timer keeps calling send_stun() on the closed transport, and the awaiting request() only finishes once all retransmissions time out (~40 s with the defaults). In aiortc this shows up as errors logged after RTCPeerConnection.close() when ICE checks were still in progress.

This adds Transaction.abort(), which cancels the retry timer and fails the transaction with a new TransactionAborted (a TransactionError, so existing except stun.TransactionError handlers in check_start keep working). StunProtocol.connection_lost() aborts all pending transactions.

Tests: test_abort (no retransmission after abort, abort is idempotent) and test_close_aborts_transactions (closing the protocol fails the pending request). Both fail without the change.

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.

2 participants