Allow cancelling TURN Allocate phase, which can block for ~7.8s if TURN server is not responding.#781
Allow cancelling TURN Allocate phase, which can block for ~7.8s if TURN server is not responding.#781smb-z wants to merge 1 commit intopion:masterfrom
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #781 +/- ##
==========================================
+ Coverage 78.38% 78.61% +0.22%
==========================================
Files 41 41
Lines 5441 5448 +7
==========================================
+ Hits 4265 4283 +18
+ Misses 945 934 -11
Partials 231 231
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
This fixes waiting for TURN Allocation to complete when Agent is closing/restarting.
1357c1e to
d9f9d1d
Compare
|
@joeturki Hi! Would you mind having a look at this PR? |
|
@smb-z Hello, Thank you so much for making this change, it makes sense. Thank you so much. |
|
Thanks, @joeturki!
It looks like a better option is to pass the context to Allocate() and process context cancelling inside the TURN client itself. |
Description
Although Agent.GatherCandidates() have a cancellable context, the turn.Client.Allocate() processing does not use it and can hang for about 7.8 seconds if the TURN server is unreachable.
This happens because Allocate() completes only after the ALLOCATE request retry limit is reached.
Ultimately, PeerConnection.Close() will block while waiting for unnecessary allocation to complete.
PR fixes this behavior by cancelling ALLOCATE phase if context was cancelled.
Caveat: If cancelled, Client.Allocate will nevertheless return error ("transaction closed") which is logged as warning here.