Skip to content

prioritize turns URLs#40

Closed
sebvanleuven wants to merge 5 commits intomainfrom
chore/webrtc_ICE_connection_setup
Closed

prioritize turns URLs#40
sebvanleuven wants to merge 5 commits intomainfrom
chore/webrtc_ICE_connection_setup

Conversation

@sebvanleuven
Copy link
Contributor

@sebvanleuven sebvanleuven commented Feb 19, 2026

aioirtc only uses the first ICE serverin a list. This might be a problem when default TURN over UDP doesn't work. TURN over TLS has the highest likelihood for success.
As the PythonSDK targets backend use cases, the use of TCP transport is not a major concern.


Summary by cubic

Prioritize TURNS (turns:) URLs per ICE server so aiortc, which uses the first TURN URI, picks the most reliable endpoint. Sorting is stable during session parsing, preserving original order within each group and improving WebRTC success when UDP TURN fails in backend SDK cases.

Written for commit a3baa31. Summary will update on new commits.

@sebvanleuven sebvanleuven requested a review from ao-anam February 19, 2026 16:25
Copy link

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2 issues found across 2 files

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.


<file name="src/anam/types.py">

<violation number="1" location="src/anam/types.py:238">
P2: The sort key includes the URL as a secondary key, so non-`turns:` entries are reordered alphabetically. This can unintentionally change the original ICE URL order (e.g., moving `stun:` ahead of `turn:`) when there are no `turns:` entries. If the goal is only to prioritize `turns:`, use a stable key that preserves original order for all other URLs.</violation>

<violation number="2" location="src/anam/types.py:278">
P2: `client_config.get("iceServers", [])` returns `None` if the API sends `iceServers: null`, and `_reorder_ice_server_urls` will then raise a `TypeError` when iterating. Coerce null to an empty list to avoid a runtime crash on valid API responses.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

sebvanleuven and others added 2 commits February 19, 2026 16:45
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
@sebvanleuven
Copy link
Contributor Author

Decided to not automatically reorder ICE servers

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