RTCDataChannel就绪状态在连接Chrome时卡住但在Firefox

时间:2017-09-06 12:53:01

标签: javascript google-chrome webrtc rtcdatachannel

我正在尝试实施RTCDataChannel(webRTC)。

它在Firefox中运行良好但在chrome中运行良好。

Chrome和Firefox都是最新版本。

Chrome中的

RTCDataChannel对象: -

RTCDataChannel {
binaryType: "arraybuffer"
bufferedAmount: 0
bufferedAmountLowThreshold: 0
id: 65535
label: "sendDataChannel"
maxRetransmitTime: 65535
maxRetransmits: 65535
negotiated: false
onbufferedamountlow: null
onclose: null
onerror: ƒ (event)
onmessage: ƒ (event)
onopen: ƒ dataChannelStateChanged()
ordered: true
protocol: ""
readyState: "connecting"
reliable: false__proto__:}

Firefox中的RTCDataChannel对象: -

DataChannel { 
binaryType: "blob"
id: 0
label: "sendDataChannel", 
reliable: true, 
readyState: "open",
bufferedAmount: 0, 
bufferedAmountLowThreshold: 0, 
onopen: dataChannelStateChanged(), 
onerror: create_peer_connection/dataChannel.onerror(), 
onclose: null, 
onmessage: create_peer_connection/dataChannel.onmessage(), 
onbufferedamountlow: null 
protocol:""
ordered:true}

我已经通过以下链接: -

  1. WebRTC data channel stack on readyState "conecting"
  2. WebRTC dataChannel.readyState stalling on "connecting"
  3. RTCDataChannel's ReadyState is not 'open'
  4. Webrtc Data Channel always in connecting state and not open
  5. 请说明这个问题背后的原因可能是什么?

1 个答案:

答案 0 :(得分:2)

我能够使用以下帖子解决它:

WebRTC DataChannel: working in Firefox but not Chrome

我不得不改变

pc = new RTCPeerConnection(configuration,
                {optional: [{RtpDataChannels: true}]});

pc = new RTCPeerConnection(configuration);