Search code examples
stunsdpturnice

Do you need exchange ICE candidates for TCP connection


A user A wants to send TCP request to user B over ICE/TURN/STUN mechanism. If user B generates a SDP with its ICE candidates and send it to user A. Is user A must answer directly to user B without to send its SDP and ICE candidates to user B? We only want TCP connection (no UDP).

Indeed, when user A receives SDP of user B with ICE candidates of user B. It can to initiate checks in order to know which IP of user B it can use to create a TCP connection (so send stun request to user B for each IP). When the TCP connection is opened. USER A send request to user B and B can response to this request over TCP, no? User B no need to check which IP of A that it can to contact because it doesn't need to send request to user A, no?


Solution

  • Doing P2P NAT traversal over TCP is a bit harder than UDP. But yes, it requires exchanging candidate addresses, including the public address obtained from a STUN or TURN server. And the main trick is often that both endpoints need to try connecting to each other at the same time.

    Read more here: https://en.wikipedia.org/wiki/TCP_hole_punching