Skip to content

Add TURN TCP transport#331

Open
gasperov wants to merge 4 commits intopaullouisageneau:masterfrom
gasperov:special/tcp3
Open

Add TURN TCP transport#331
gasperov wants to merge 4 commits intopaullouisageneau:masterfrom
gasperov:special/tcp3

Conversation

@gasperov
Copy link
Copy Markdown

@gasperov gasperov commented Apr 6, 2026

Implement TURN relay over TCP (transport=TCP) as an alternative to the default UDP transport. This allows WebRTC connectivity in environments that block UDP entirely.

@gasperov gasperov force-pushed the special/tcp3 branch 3 times, most recently from aa5ef5e to ff09a07 Compare April 6, 2026 23:15
@gasperov gasperov changed the title Special/tcp3 Add TURN TCP transport Apr 6, 2026
@gasperov gasperov marked this pull request as ready for review April 7, 2026 20:24
Comment thread include/juice/juice.h Outdated
Comment thread include/juice/juice.h Outdated
Comment thread src/agent.h Outdated
Comment thread src/agent.c Outdated
Comment thread src/agent.c Outdated
Comment thread src/conn.c Outdated
Comment thread src/tcp.h Outdated
Comment thread src/tcp.h Outdated
Copy link
Copy Markdown
Owner

@paullouisageneau paullouisageneau left a comment

Choose a reason for hiding this comment

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

This might kind of work, but there are a bunch of issues with the implementation.

@gasperov gasperov marked this pull request as draft April 17, 2026 20:01
gasperov and others added 3 commits April 18, 2026 20:44
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
@gasperov gasperov marked this pull request as ready for review April 18, 2026 19:18
TCP TURN relay entries start in STANDBY when any UDP probe exists (STUN
servers or UDP TURN). TCP activates only after all UDP probes have each
retransmitted TURN_TCP_FALLBACK_RETRANSMISSIONS times without response,
indicating UDP is globally blocked. If any UDP relay succeeds first,
TCP is cancelled.

- Add AGENT_STUN_ENTRY_STATE_STANDBY and is_tcp_fallback flag
- Replace per-pair fallback_entry with global counter-based trigger
  (O(1) per probe, single O(n) activation scan when all probes report)
- Add agent_conn_turn_tcp_state to handle TCP CONNECTED/FAILED callbacks
  and avoid log spam while waiting for TCP connection
- Add juice_get_selected_relay_transport() public API
- Expand test_turn_udp_preferred: two scenarios (STUN+TCP and STUN+UDP+TCP)
  verifying both SERVER and UDP RELAY entries participate in probe count

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
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