peers / peerjs

Simple peer-to-peer with WebRTC.
https://peerjs.com
MIT License
12.48k stars 1.43k forks source link

error event not triggered #626

Open tiofabby opened 4 years ago

tiofabby commented 4 years ago

Hello, I am able to send data between two peers, using your peerjs-server (v0.2.9) without any issues and it works fine. Only problem I am facing is that if one of the 2 peers is offline, the peer.connect() to such user (being offline) will never trigger the 'error' event even if we listen to it. Is it on purpose or am I missing something?

Please note also that if peer is online at the beginning, I am then able to connect to it. Then if such peer gets OFFLINE suddenly, then in that case the 'error' event is correctly triggered!!

So the issue here is only when peer is offline since the beginning and we are never able to connect to it, then in that case, the 'error' event is never triggered.

Thank you Fabrice


    myConnections[peerId] = peer.connect(peerId)
    myConnections[userPeerId].on('error', function(err) {
      Log.error('Error with connection', userPeerId, err)
      // NEVER GETTING HERE WHEN PEER IS ALREADY OFFLINE
    })
begoat commented 4 years ago

@tiofabby Hi, tifabby. I came across the same problem. I caught error in the error callback of peer object temporarily, according to the doc

peer.on('error', function(err) { ... });
// Errors from the underlying socket and PeerConnections are forwarded here.
tiofabby commented 4 years ago

Hello @begoat Thanks for your feedback but I had that in place already and if I try to connect to a peer not being connected to the server, the peer.on('error', function(err) { ... }) is not being triggered neither.

I am thinking about putting a Timeout to close these ghost connections never being opened.. but I would prefer peerjs to have these detected so I can trigger their closing automatically.

Thanks

begoat commented 4 years ago

Are there any error logs on console?

Wednesday, February 19, 2020, 17:56 +0800 from notifications@github.com notifications@github.com:

Hello @begoat Thanks for your feedback but I had that in place already and if I try to connect to a peer not being connected to the server, the peer.on('error', function(err) { ... }) is not being triggered neither. I am thinking about putting a Timeout to close these ghost connections never being opened.. but I would prefer peerjs to have these detected so I can trigger their closing automatically. Thanks — You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub , or unsubscribe .

tiofabby commented 4 years ago

Hi @begoat No the peerjs server is not generating any errors. Logs are only showing who is connected or who gets disconnected but no error regarding the fact that someone asked for a connection that cannot be established. Thank you Fabrice