Skip to content Skip to sidebar Skip to footer

Force UDP For Webrtc Peer Connection

I am using webrtc RtcPeerConnection API in Chrome. My local SDP offer is like this a=candidate:0 1 UDP 2122252543 10.100.49.26 59882 typ host a=candidate:1 1 TCP 2105524479 10.100.

Solution 1:

You can just remove the line which contains the a=candidate TCP line, before calling the setLocalDecription and sending to the peer.

However, chrome by default supports ICE trickle to speed up the connection setup process and does not require to gather all the candidates before sending the SDP. So, you can set the SDP immediately after generation and easily filter out the unwanted candidates before sending them to the other peer in the onicecandidate callback.

rtcPeerConnection.onicecandidate = event => {
      if (event.candidate && event.candidate.protocol !== 'tcp') {
         // send to peer
      }
}

Post a Comment for "Force UDP For Webrtc Peer Connection"