Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

126
Vistas
Web RTC connection is not established

When I run this code connection is not established,

  • in firefox console error "WebRTC: ICE failed, add a STUN server and see about:webrtc for more details" shows up and dataChannel.readyState is connecting

  • in Chrome console error does not show up but again dataChannel.readyState is connecting

     var localconn, remoteconn, dataChannel, recievedDataChannel;
     connect();
     async function connect(){
         localconn = new RTCPeerConnection();
         remoteconn = new RTCPeerConnection();
         dataChannel = localconn.createDataChannel("dataChannel");
    
         dataChannel.onopen = e =>{
             console.log("data channel is open");
         }
         dataChannel.onmessage = e=>{
             console.log("new message: " +e.data);
         }
    
     remoteconn.ondatachannel = e =>{
         recievedDataChannel = e.channel;
         recievedDataChannel.onmessage = e=>{
             console.log("new message from remote : " +e.data);
         }
    
     }
    
     var offer = await localconn.createOffer();
     await localconn.setLocalDescription(offer);
     await remoteconn.setRemoteDescription(offer);
     var answer = await remoteconn.createAnswer();
     await remoteconn.setLocalDescription(answer);
     await localconn.setRemoteDescription(answer);
    

    }

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

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

about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda