peerjs/webrtc iceConnectionState失败 [英] peerjs/webrtc iceConnectionState failed

查看:952
本文介绍了peerjs/webrtc iceConnectionState失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

一段时间以来,我一直在试图解决这个问题.我正在尝试使用peerjs建立一个简单的连接.我可以成功连接到ID为USER_ID的对等方.但是,他们无法连接到我.他们尝试连接时,我收到以下日志.

I've been trying to figure this out for a while. I'm trying to establish a simple connection using peerjs. I can connect successfully to the peer with id USER_ID. However, they are unable unable to connect to me. I receive the following log when they try to connect.

iceConnectionState最终更改为failed,并且无法接收任何数据.

iceConnectionState is changed to failed eventually and no data can be recieved.

  • 该应用程序正在使用peerjs云服务器
  • 我正在使用最新版本的Chrome.他们尝试使用最新版本的Chrome和Firefox
  • 他们已关闭所有防火墙
  • 甚至尝试了 peerjs聊天示例,但失败并出现相同的错误.
  • The application is using the peerjs cloud server
  • I'm using the latest version of Chrome. They have tried using latest versions of Chrome and Firefox
  • They have switched off any firewalls
  • Have even tried the peerjs chat example and it fails with the same error.

有人知道为什么会发生这种情况吗?

Any idea why this might happen / going on here?

任何帮助表示赞赏!


peer.min.js:1 PeerJS:  Socket open
peer.min.js:1 PeerJS:  Creating RTCPeerConnection.
peer.min.js:1 PeerJS:  Listening for ICE candidates.
peer.min.js:1 PeerJS:  Listening for `negotiationneeded`
peer.min.js:1 PeerJS:  Listening for data channel
peer.min.js:1 PeerJS:  Listening for remote stream
peer.min.js:1 PeerJS:  Setting remote description RTCSessionDescription
peer.min.js:1 PeerJS:  Added ICE candidate for: USER_ID
peer.min.js:1 PeerJS:  Set remoteDescription: OFFER for: USER_ID
peer.min.js:1 PeerJS:  Created answer.
peer.min.js:1 PeerJS:  Set localDescription: answer for: USER_ID
peer.min.js:1 PeerJS:  Received ICE candidates for: USER_ID
peer.min.js:1 PeerJS:  Added ICE candidate for: USER_ID
peer.min.js:1 PeerJS:  Received ICE candidates for: USER_ID
peer.min.js:1 PeerJS:  Added ICE candidate for: USER_ID
peer.min.js:1 PeerJS:  Received ICE candidates for: USER_ID
peer.min.js:1 PeerJS:  iceConnectionState is disconnected, closing connections to USER_ID

推荐答案

我遇到了完全相同的问题.添加STUN TURN服务器应该可以解决该问题.

I had the exact same issue. Adding the STUN TURN servers should resolve the issue.

客户端代码

peer = new Peer(this.api.currentUserValue().id+'-'+this.api.currentUserValue().first_name,{
                                                    host: 'localhost',
                                                    port: 8080,
                                                    path: '/api',
                                                    debug: 3,
                                                    config: { 'iceServers': [
                                                      { 'url': 'stun:stun.l.google.com:19302' },
                                                      { 'url': 'turn:numb.viagenie.ca',credential: 'xxxx', username:'xxxx@gmail.com'  } ] } // this is must for keeping the connection open
                                                      });

服务器端代码

var express = require('express');
var app = express();
var server = require('http').createServer(app);
var io = require('socket.io')(server);
var expressPeerServer = require('peer').ExpressPeerServer;
var path = require('path');



app.set('port', (process.env.OPENSHIFT_NODEJS_PORT || "8080"));
app.set('host', (process.env.OPENSHIFT_NODEJS_IP || "127.0.0.1"));

app.use(express.static(path.join(__dirname, '/client')));
app.use('/api', expressPeerServer(server, {debug:true}));




server.listen(app.get('port'),app.get('host'),function(){
  console.log('Server running at %s:%s',app.get('host'),app.get('port'));
});

这篇关于peerjs/webrtc iceConnectionState失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆