小编Isa*_*won的帖子

WebRTC 在控制台上的 RTCPeerConnection 错误上无法执行“addIceCandidate”,但仍然可以显示远程和本地视频

我正在尝试使用 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)

javascript google-chrome socket.io webrtc reactjs

9
推荐指数
1
解决办法
8368
查看次数

标签 统计

google-chrome ×1

javascript ×1

reactjs ×1

socket.io ×1

webrtc ×1