当前位置:网站首页>Easyrtc call error `failed to execute'send'on'rtcdatachannel'

Easyrtc call error `failed to execute'send'on'rtcdatachannel'

2022-06-24 06:26:00 Tsingsee green rhino video

WebRTC The existence of Internet brings a new mode to online video conference system ,TSINGSEE Qingxi video development of web video conference system EasyRTC A combination of webrtc and rtmp/rtsp The advantages of the scheme , Support one-to-one 、 One to many video conference interactive calls , Meet voice social networking 、 Online education and training 、 Video conference and telemedicine , new EasyRTC The project will meet you soon .

In the test EasyRTC The new version of point-to-point call function , There is an error :Failed to execute ‘send’ on ‘RTCDataChannel’: RTCDataChannel.readyState is not ‘open’, And can not successfully send messages to the other party .

See the code below :

// Instantiate the send channel 
sendChannel = localConnection.createDataChannel('webrtc-datachannel');
//onopen Event monitoring 
sendChannel.onopen = this.onSendChannelStateChange;
//onclose Event monitoring 
sendChannel.onclose = this.onSendChannelStateChange;

The above code does not find errors , Therefore, it is suspected that the problem of calling sequence leads to . Look at the code again , Found sending offer After the message , The corresponding data transmission channel is created , The problem may arise here .

To solve this problem , We will adjust the code sequence as follows :

// Instantiate the send channel 
    sendChannel = localConnection.createDataChannel('webrtc-datachannel');
    //onopen Event monitoring 
    sendChannel.onopen = this.onSendChannelStateChange;
    //onclose Event monitoring 
    sendChannel.onclose = this.onSendChannelStateChange;

    try {
      console.log('localConnection Create proposal Offer Start ');
      // Create proposal Offer
      const offer = await localConnection.createOffer();
      // establish Offer success 
      await this.onCreateOfferSuccess(offer);
    } catch (e) {
      // establish Offer Failure 
      this.onCreateSessionDescriptionError(e);
}

After modification , Can send messages normally .

原网站

版权声明
本文为[Tsingsee green rhino video]所创,转载请带上原文链接,感谢
https://yzsam.com/2021/07/20210719185951171p.html

随机推荐