我正在尝试使用 webRTC 连接两个对等点。我能够正确显示本地和远程视频,但是一旦远程视频出现,候选对象就会变为null
并在控制台上记录以下错误消息。
TypeError: Failed to execute 'addIceCandidate' on 'RTCPeerConnection': Candidate missing values for both sdpMid and sdpMLineIndex
Run Code Online (Sandbox Code Playgroud)
我正在使用两台单独的笔记本电脑来测试连接,并且由于远程和本地视频都在显示,我认为我已经成功连接了两个对等点,但由于错误消息我不确定。
关于为什么会发生这种情况的任何想法?我什至成功连接了两个对等点吗?
下面是代码。
谢谢!
前端
import React, { Component } from 'react';
import io from 'socket.io-client';
class App extends Component {
constructor(props) {
super(props);
this.room = 'test-room';
this.socket = io.connect('http://localhost:5000');
this.localPeerConnection = new RTCPeerConnection({
iceServers: [
{
urls: 'stun:stun.l.google.com:19302'
}
]
});
this.remotePeerConnection = new RTCPeerConnection({
iceServers: [
{
urls: 'stun:stun.l.google.com:19302'
}
]
});
};
componentDidMount() {
this.socket.on('connect', () => …
Run Code Online (Sandbox Code Playgroud)