Search code examples
javascriptgoogle-chromewebrtcrtcdatachannel

RTCDataChannel ready state stuck at connecting in chrome but working in Firefox


I am trying to implement RTCDataChannel(webRTC).

It's working good in Firefox but not in chrome.

Both Chrome and Firefox are of the latest version.

RTCDataChannel object in Chrome :-

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__:}

RTCDataChannel object in Firefox :-

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}

I have already gone through below links:-

  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

Please suggest what could be the reason behind the issue in chrome?


Solution

  • I was able to resolve it using the following post :

    WebRTC DataChannel: working in Firefox but not Chrome

    I had to change

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

    to

    pc = new RTCPeerConnection(configuration);