Javascript 未能执行';setRemoteDescription';在';RTPEERCONNECTION';
我正在尝试使用和设置webrtc信令服务。但在执行时,我得到以下错误:Javascript 未能执行';setRemoteDescription';在';RTPEERCONNECTION';,javascript,webrtc,signaling,simple-peer,Javascript,Webrtc,Signaling,Simple Peer,我正在尝试使用和设置webrtc信令服务。但在执行时,我得到以下错误:Uncaught(in promise)错误:InvalidStateError:未能在“RTPeerConnection”上执行“setRemoteDescription”:未能设置远程应答sdp:在错误状态下调用:kStable 代码如下: navigator.mediaDevices.getUserMedia({video: true, audio: false}) .then((stream) => {
Uncaught(in promise)错误:InvalidStateError:未能在“RTPeerConnection”上执行“setRemoteDescription”:未能设置远程应答sdp:在错误状态下调用:kStable
代码如下:
navigator.mediaDevices.getUserMedia({video: true, audio: false})
.then((stream) => {
const signalhub = require('signalhub')
const hub = signalhub('live-video', [
'http://localhost:8080'
])
const Peer = require('simple-peer')
const peer = new Peer({
initiator: location.hash == '#init',
trickle: false,
stream: stream
})
peer.on('signal', (data) => {
let yourID = JSON.stringify(data)
console.log('your ID: ', yourID)
hub.broadcast('update', yourID)
})
hub.subscribe('update').on('data', (data) => {
let otherID = JSON.parse(data)
console.log('other ID: ', otherID)
peer.signal(otherID)
})
// peer.on('stream', (stream) => {
// const video = document.createElement('video')
// document.body.appendChild(video)
// video.src = window.URL.createObjectURL(stream)
// video.play()
// })
})
.catch((err) => {
document.write(err)
})
我遵循了凯尔·罗宾逊·杨的两篇教程。同样的问题,你找到答案了吗?