Webrtc: Force Peers To Use Turn Server
Solution 1:
I have no idea if or when the browsers will support this but have a look at the "ICE candidate policy" in section 4.1.1 of draft-ietf-rtcweb-jsep-08, you can see how setting the policy to "relay" will do what you want. In the current W3C API draft this is set using an RTCIceTransportPolicy value of "relay" for the iceTranportPolicy field in the configuration. Search for RTCIceTransportPolicy in https://w3c.github.io/webrtc-pc/
Solution 2:
just adding this to close the question,
function onIceCandidate(event, targetSessionID, targetUserName) {
if (event.candidate) {
var candidate = event.candidate.candidate;
if(candidate.indexOf("relay")<0){ // if no relay address is found, assuming it means no TURN serverreturn;
}...
The above code works, checked to wireshark
,
after adding the if(candidate.indexOf("relay")<0)
condition, communication takes place only through TURN server, if server is not present/ incorrect details, connection state get's struck at new
Edit: like cullen has said in his answer, according to w3 webrtc, passing relay
as iceTransportPolicy
should work, but I haven't checked if it is implemented in Firefox and Chrome yet...
Solution 3:
Solution 4:
You can now force turn by using the iceTransportPolicy attribute
let pc = new RTCPeerConnection({ iceTransportPolicy : "relay" })
https://developer.mozilla.org/en-US/docs/Web/API/RTCConfiguration/iceTransportPolicy
Post a Comment for "Webrtc: Force Peers To Use Turn Server"