【问题标题】:webrtc peer connection: can not create an answerwebrtc 对等连接:无法创建答案
【发布时间】:2018-05-30 01:57:26
【问题描述】:

当我无法创建答案但连接状态已经是 have-remote-offer 时,我遇到了问题。

代码:

pc.ontrack = function(evt) {

  // signaling state is have-remote-offer
  logEvent('REMOTE', 'signalingstate', pc.signalingState);

  pc.createAnswer() // error here
    .then((answer) => {
       localConnection.setLocalDescription(answer);
       logEvent('REMOTE', 'signalingstate', pc.signalingState);

       socket.emit('session_description', JSON.stringify({ desc: answer.toJSON() }));
  });
};

错误:

Uncaught (in promise) DOMException: Peer Connection cannot create an answer in a state other than have-remote-offerhave-local-pranswer

有什么想法吗?

【问题讨论】:

    标签: javascript webrtc


    【解决方案1】:

    从 ontrack 调用 createAnswer 通常不会起作用。您需要从 setRemoteDescription .then() 调用它

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-05-24
      • 2018-06-27
      • 2022-01-18
      • 2017-08-25
      • 2018-12-08
      • 2013-08-07
      • 1970-01-01
      相关资源
      最近更新 更多