node.js - peerjs连接打开,但没有收到数据

标签 node.js websocket webrtc node-webkit peerjs

这是我的设置

服务器

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/

相关文章:

angularjs - Node : npm install command shows error

javascript - RxJS 5 - websocket 数组消息

javascript - 改变质量的 webRTC

javascript - 如何通过网站在 IOS 设备上录制音频

使用 WebRTC 的 Android 屏幕共享

javascript - 如何在 NodeJS 中创建加密和解密函数?

javascript - 将 Express.js-REST-Endpoint 与 Meteor 应用程序集成

arrays - Node +蒙戈: adding record to array inside collection

websocket - 错误 : Error when readinrror: Error when reading 'bin/main.dart' : The system cannot find the path specified

websocket - 在单个 Jetty 服务器中添加不同的处理程序