Dawid
Dawid

Reputation: 3

Web RTC connection is not established

When I run this code connection is not established,

Upvotes: 0

Views: 528

Answers (1)

Stefan
Stefan

Reputation: 26

You need a listener for ICE candidates on the peer connection and apply those to the other peer.

localconn.onicecandidate = function(event) {
  if (event.candidate) {
    remoteconn.addIceCandidate(event.candidate);
  } else {
    // All ICE candidates have been sent
  }
}

remoteconn.onicecandidate = function(event) {
  if (event.candidate) {
    localconn.addIceCandidate(event.candidate);
  } else {
    // All ICE candidates have been sent
  }
}

See also https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/onicecandidate

Upvotes: 1

Related Questions