WebRTC:createOffer在Chrome中调用两次成功回调 [英] WebRTC: createOffer's success callback called twice in Chrome

查看:690
本文介绍了WebRTC:createOffer在Chrome中调用两次成功回调的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用


I'm playing with WebRTC and following this article. Now I experiencing strange behaviour in Chrome (Mozilla work fine) - when I call createOffer I pass a success callback (named RTCSessionDescriptionCallback in W3C draft) in and then strange thing is that in Chrome this callback get called twice! This leads setLocalDescription to be also called twice and first it succeed but second call return error:

failed to set description SetLocalDescription failed: Failed to push down offer transport description. 

So can any one suggest why this happens on chrome (I use version 31.0.1650.63)?

Here is the plunk for this.

解决方案

I already expected that this was a problem with onnegotiationneeded and yes. When you change line 37 to console.trace, you can see which code called your function createOffer():

What you want to do is create and set an offer first, and then add the onnegotiationneeded. This will prevent any errors. As you are following a tutorial, see this working example

这篇关于WebRTC:createOffer在Chrome中调用两次成功回调的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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