WebRTC: force peers to use TURN server

后端 未结 3 1033
温柔的废话
温柔的废话 2021-02-04 05:18

I have a webrtc application, it works fine, but for testing purposes, I need to test if my TURN server works, but because both the testing devices are within the same network, I

3条回答
  •  半阙折子戏
    2021-02-04 05:38

    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 server
            return;
        }...
    

    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...

提交回复
热议问题