0

I have an application which is using PeerJS for video streaming, and I'm using a node based Peer Server running on an Ubuntu Server instance, over HTTPS (SSL certificates installed on the server).

This is how I instanciate my PeerServer :

var server = PeerServer({
port:55127,
path:'/',
debug:true,
ssl:{
    key: fs.readFileSync('/etc/apache2/ssl/mykey.key'),
    cert: fs.readFileSync('/etc/apache2/ssl/mycert.crt')
    }
});

This is how I create a peer connection :

var peer = new Peer('peerHost',{host: 'myhost.com', port: 55127, path: '/'})

Regarding ports, I have allowed 55127 both in UFW and in the router.

For some strange reason, my peer connections and video streaming are working perfectly in the LAN, but failing over the internet - although sometimes they work, for instance in occasions over a 3G mobile network.

While debugging the Peer connection, I stumbled upon these "errors":

PeerJS: VP9 Codec: null    
PeerJS:  iceConnectionState is disconnected, closing connections to (...)

No errors on the server side, all these are either on the host or on the client.

This issue is similar to this, this and this.

Does anyone have any idea of what could be wrong and how it could be fixed ?

Thanks in advance.

4

1 回答 1

1

好的,似乎我遇到了这个问题,在任何家用路由器中,一个非常常见的 NAT/防火墙场景会阻止我的 PeerJS 服务器需要访问的端口,从而禁止代理连接,并且不允许视频被流式传输。

解决方案是使用中间 TURN 服务器来覆盖 NAT 设置。

var peer = new Peer({host: 'host.com', port: 55127, path: '/', debug:true, config: {'iceServers': [{ url: 'stun:stun.l.google.com:19302' },{ url: 'turn:numb.viagenie.ca', username: 'username@gmail.com', credential: 'password' }]}});
于 2016-11-15T11:36:09.423 回答