Javascript WebRTC onicecandidate从不在chrome中点火

Javascript WebRTC onicecandidate从不在chrome中点火,javascript,google-chrome,firefox,webrtc,Javascript,Google Chrome,Firefox,Webrtc,我的webrtc web应用程序从来都不是OnicCandidate。 当我查看本地(Webrtc对象)对象时,会设置localdescription和remotedescription。 在firefox中,它触发onicecandidate,但event.candidate为null 我花了好几个小时试图解决这个问题,但还是做不到 谁能解决这个问题 如何使onicecandidate事件被激发 let local = new RTCPeerConnection(); let remo

我的webrtc web应用程序从来都不是OnicCandidate。 当我查看本地(Webrtc对象)对象时,会设置localdescription和remotedescription。 在firefox中,它触发onicecandidate,但event.candidate为null

我花了好几个小时试图解决这个问题,但还是做不到

谁能解决这个问题

如何使onicecandidate事件被激发

  let local = new RTCPeerConnection();
  let remote = new RTCPeerConnection();
  try {
    local.createOffer().then(function(sdp) {
      console.log("Offer Created by Local: " + sdp.sdp);
      local.setLocalDescription(sdp);
      remote.setRemoteDescription(sdp);

      remote.createAnswer().then(function(sdp){
        console.log("Answer Created by Remote: " + sdp.sdp);
        remote.setLocalDescription(sdp);
        local.setRemoteDescription(sdp);
        local.onicecandidate = localicecandidate;
        remote.onicecandidate = remoteicecandidate;

        let channel = local.createDataChannel("channel");
        channel.onopen = function(event) {
          console.log("Channel opened");
        }
        channel.onmessgae = function(event) {
          console.log(event.data);
        }

        remote.ondatachannel = function(event) {
          let channel = event.channel;
          channel.onopen = function(event) {
            channel.send("Hi!");
          }
        }

        function localicecandidate (event) {
          console.log("Local got new Ice Candidate: " + event.candidate);
          remote.addIceCandidate(new RTCIceCandidate(event.candidate));
        }
        function remoteicecandidate (event) {
          console.log("Remote got new Ice Candidate: " + event);
          local.addIceCandidate(new RTCIceCandidate(event.candidate));
        }

      }); 
    })
  }

  catch (e) {
    console.log("Got Error" + e);
  }

在调用createOffer之前,您没有调用createDataChannel,因此SDP不包含m=行。没有m-lines,ICE就没有什么可以谈判的

移动
let channel=local.createDataChannel(“通道”)在createOffer之前。

在Messgae上--您有一个输入错误。