Video streaming 在WebRTC中处理网络中断

Video streaming 在WebRTC中处理网络中断,video-streaming,webrtc,amazon-kinesis,Video Streaming,Webrtc,Amazon Kinesis,我正在使用手机应用程序和网站之间的视频聊天连接。我需要在web端处理网络中断。让我解释一下我已经做过的步骤 我可以在事件侦听器上检测到网络已断开连接 peerConnection.addEventListener('iceconnectionstatechange',事件=>{ if(event.target.connectionState=='connected'&&event.target.iceConnectionState=== “断开连接”){ //做一些事情来处理网络中断 } }

我正在使用手机应用程序和网站之间的视频聊天连接。我需要在web端处理网络中断。让我解释一下我已经做过的步骤

我可以在事件侦听器上检测到网络已断开连接

peerConnection.addEventListener('iceconnectionstatechange',事件=>{ if(event.target.connectionState=='connected'&&event.target.iceConnectionState=== “断开连接”){ //做一些事情来处理网络中断 } } 在这种情况下,我将以循环时间间隔向服务器发送一个请求(测试api),以检测网络是否正常。 如果网络连接正常,我将运行…()

const newOffer=wait peerConnection.createOffer({iceRestart:true})
等待peerConnection.setLocalDescription(newOffer)
之后,我可以看到连接已建立(connectionState/iceConnectionState状态已连接),但我无法接收任何数据流(来自移动用户的视频已冻结)。但是,1分钟后,发送流将显示在移动端


谢谢!

我发现我必须发送sdp报价。因此代码将类似于

const newOffer=wait peerConnection.createOffer({iceRestart:true})
等待peerConnection.setLocalDescription(newOffer)
//发送sdp报价
master.signalingClient.sendSdpOffer(peerConnection.localDescription,viewerClientID)
现在它的工作如预期