Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Failed to execute 'send' on 'RTCDataChannel': RTCDataChannel.readyState is not 'open'

I am trying to learn WebRTC . I copied some codes and i get this error:

Failed to execute 'send' on 'RTCDataChannel': RTCDataChannel.readyState is not 'open'

Any one can help?

code score: http://www.tutorialspoint.com/webrtc/webrtc_text_demo.htm

like image 812
GentleMan Avatar asked Aug 17 '16 00:08

GentleMan


1 Answers

Add ondatachannel handling after removing {optional: [{RtpDataChannels: true}]}:

  myConnection.onicecandidate = function (event) { 

     if (event.candidate) { 
        send({ 
           type: "candidate", 
           candidate: event.candidate 
        });
     } 
  }; 

  myConnection.ondatachannel = function(event) {
     var receiveChannel = event.channel;
     receiveChannel.onmessage = function(event) {
        console.log("ondatachannel message:", event.data);
     };
  };

  openDataChannel();
like image 174
bronyuk Avatar answered Nov 14 '22 21:11

bronyuk