2016-04-17 8 views
0

ブラウザのコンソールでエラーが発生しました(クロムのみ、Firefoxではエラーなし)エラー: 'RTCPeerConnection'で 'addIceCandidate' :ICE候補を追加できませんでした。WebRTC - 'RTCPeerConnection':ICE候補を追加できませんでした

私はチュートリアルに続き、node2を使用して動作するp2pビデオチャットを取得できました。今私は、サーバー側でFlaskとPythonを使用しており、クライアント側ではanglejsを使用しています。

2つのピアのシグナリングプロセスは、angle-socketioで実行されています。

console.log("The user connected to the socket"); 
socket.emit('readyToJoinRoom', {"signal_room": SIGNAL_ROOM}); 

//Send a first signaling message to anyone listening 
//This normally would be on a button click 

socket.emit('signal',{"type":"user_joined", "message":"Are you ready for a call?", "room":SIGNAL_ROOM}); 

socket.forward('signaling_message', $scope); 
$scope.$on('socket:signaling_message', function (ev, data) { 
    displaySignalMessage("Signal received: " + data.type); 
    // Setup the RTC Peer Connection object 
    if (!rtcPeerConn) { 
      startSignaling(); 
    } 

    if(data.type != "user_joined") { 
     console.log(data.message); 
     var message = JSON.parse(data.message); 
     console.log(message); 
     if(message.sdp) { 
      console.log("inside 2nd if statement"); 
      rtcPeerConn.setRemoteDescription(new RTCSessionDescription(message.sdp), function() { 

      // if we received an offer, we need to answer 
      if(rtcPeerConn.remoteDescription.type === 'offer') { 
        console.log("inside third if for remoteDescription."); // This never executes, error happens right before this line 
        rtcPeerConn.createAnswer(sendLocalDesc, logError); 
      } 
      }, logError); 
    } 
    else { 
    console.log("addedddddddd ice candidate."); 
    rtcPeerConn.addIceCandidate(new RTCIceCandidate(message.candidate)); 
    }  
} 
}); 

2人で部屋に入ると、startSignaling()メソッドが呼び出されます。それはローカルの説明を設定し、3つの氷の候補を完了してからSDPを受け取るが、これは決して真ではないif(rtcPeerConn.remoteDescription.type === 'offer')同じタイプのコンソールでSDPを出力する提供。私はなぜこのif文の中に決して進まないのか分かりません。なぜ私はエラーが発生しているのか分かりません。ご質問がありましたら、尋ねてください。助けてくれてありがとう。

答えて

1

私はRTCSessionDescriptionのコンストラクタは、種類やSDPについての情報を必要とするため

rtcPeerConn.setRemoteDescription(new RTCSessionDescription(message.sdp),... 

が動作しませんと思います。試してみてください:

var desc = new RTCSessionDescription(); 
desc.sdp = message.sdp; 
desc.type = "offer"; 
rtcPeerConn.setRemoteDescription(desc,..... 

私もJSONからRTCSessionDescriptionを構築するいくつかの問題がありました。 これは役に立ちます。

+0

私はこれを試してもうまくいかなかった= [。それでも同じエラー。 – sebenalern

関連する問題