webrtc 对等连接:无法创建答案 [英] webrtc peer connection: can not create an answer

查看:55
本文介绍了webrtc 对等连接:无法创建答案的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have a problem when I can't create an answer but the connection state is already 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() }));
  });
};

错误:

未捕获(承诺)DOMException:对等连接无法在除have-remote-offerhave-local-pranswer

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

有什么想法吗?

推荐答案

从 ontrack 调用 createAnswer 通常不会起作用.你会想从 setRemoteDescription .then()

calling createAnswer from ontrack is not going to work typically. You'll want to call it from the setRemoteDescription .then()

这篇关于webrtc 对等连接:无法创建答案的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆