2

I have created a simple prototype in WebRTC that uses test STUN servers provided by Google:

var servers = [
   "stun:stun.l.google.com:19302",
   ...
];

I ran two separate apps (without a local server - i.e. NodeJS).
I just opened the file directly via web browser.

It successfully created a RTCPeerConnection and RTCDataChannel objects.

However, onopen handler in RTCDataChannel was never triggered.
The readyState of the data channel is always "connecting".

SAMPLE CODE:

  window.localConnection = localConnection =
      new RTCPeerConnection(configuration); // configuration.iceServer

  localChannel = localConnection.createDataChannel('data');
  localChannel.onopen = function () { // never triggered
     var readyState = localChannel.readyState;
     console.log('Local channel state is: ' + readyState);
  }

QUESTIONS:

1. Do I need a server (like NodeJS) to have a readyState set to "open"?
2. When would readyState transition to "open" state?

Joseph D.
  • 11,804
  • 3
  • 34
  • 67
  • 1
    Are you doing the rest of the RTC negotiation as well…? I.e. exchanging SDP offers and ICE candidates? – deceze May 17 '18 at 08:28
  • @deceze, yes add track, offer, set descriptor, answer and add ice candidate. they all work fine. but I can't send for the data channel is not open. – Joseph D. May 17 '18 at 08:30
  • @deceze, question. in this [sequence diagram](https://www.w3.org/TR/webrtc/images/ladder-2party-simple.svg), 15 will send offer to the remote connection. Is this via data channel? – Joseph D. May 18 '18 at 01:37
  • 1
    No. That is still part of the negotiation and exchanging of ICE candidates which must complete in order to establish a connection. Data channels then go over an established connection. – deceze May 18 '18 at 05:37
  • @deceze, thank you for confirming. I used Node.js for my Signaling server. atleast it cleared my confusion about #7 in the sequence. – Joseph D. May 18 '18 at 05:41

0 Answers0