这是我的设置
服务器
var webrtcServer = new PeerServer({
port: 9000,
path: "/wrtc"
});
对等 1(在 node-webkit 应用程序内运行)
var peer = new Peer( 'masterName', {
host: 'localhost',
port: 9000,
path: '/wrtc'
});
peer.on( 'connection', function(conn) {
conn.on( 'open', function() {
console.log( "peer connected" ); // This fires as expected
conn.send( "helo" );
});
});
对等点 2(在浏览器内运行)
conn = peer.connect('masterName');
conn.on('open', function(){
console.log( "WebRTC connection open" ); // This fires as expected
});
conn.on('data', function(data) {
debugger;
console.log("data"); // This never hits
});
如果我在peer.js中设置断点,则不会收到任何数据。如果我将连接设置为可靠,则不会发生任何变化。还有什么我可以尝试的吗?
最佳答案
我遇到了类似的问题,添加 STUN 服务器为我解决了这个问题。另请参阅 peerjs Google group 中的讨论
peer = new Peer(
{
host: 'localhost',
port: 9000,
debug: true,
config: { 'iceServers': [
{ 'url': 'stun:stun.l.google.com:19302' }
] }
});
关于node.js - peerjs连接打开,但没有收到数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23902598/