【发布时间】:2020-09-11 13:38:55
【问题描述】:
我正在使用Amazon Kinesis Video Streams WebRTC 在移动应用程序和网站之间建立视频聊天连接。我需要在 Web 端处理网络中断。让我解释一下我已经完成的步骤。
我可以在事件监听器上检测到网络已断开...
peerConnection.addEventListener('iceconnectionstatechange', event => {
if (event.target.connectionState === 'connected' && event.target.iceConnectionState ===
'disconnected') {
// do something to handle network interruption
}
}
在这种情况下,我将在循环时间间隔内向服务器(测试 api)发送请求,以检测网络是否正常。 在网络连接正常的情况下,我会运行... (reference)
const newOffer = await peerConnection.createOffer({ iceRestart: true })
await peerConnection.setLocalDescription(newOffer)
之后我可以看到连接已建立(connectionState/iceConnectionState 状态已连接)但我无法接收任何数据流(来自移动用户的视频被冻结)。但是 1 分钟后,发送流将显示在移动端。
谢谢!
【问题讨论】:
标签: video-streaming webrtc amazon-kinesis