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.

Community
  • 1
  • 1

1 Answers1

1

OK, seems that I was suffering from this issue, where a very common NAT/Firewall scenario, in any home-used router would block the ports that my PeerJS server needed to access, thus inhibiting the broker connection, and not allowing the video to be streamed.

The solution was to use an intermediate TURN server in order to override the NAT settings.

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' }]}});