Closed RangerMauve closed 10 years ago
Hey--you should get an error if the peer doesn't exist. Are you listening for errors on your peer object?
Michelle
On Wed, May 28, 2014 at 8:11 AM, RangerMauve notifications@github.comwrote:
In my application, I noticed that if I tried to connect to a peer id that nobody was listening on anymore, the caller wouldn't get any sort of error or notification about it. This can leave my app in a strange state where it calls and just waits for the call to go through forever.
— Reply to this email directly or view it on GitHubhttps://github.com/peers/peerjs/issues/197 .
Thanks for the quick reply.
Yes. In my code I have
call.on("error", function (err) {
console.error(err);
});
My flow looks like this
I attach the listeners for all the possible events directly after making the call.
var call = peer.call(room, localStream);
init_call(call);
init_call
listens to "stream", "close", and "error" in that order.
Are you running your own servers? Sometimes websockets don't close properly
on refresh, so the server isn't aware that you've disconnected yet. You
could try adding an onbeforeunload
handler to your page that will close
the peer when refreshing.
Michelle
On Wed, May 28, 2014 at 10:35 AM, RangerMauve notifications@github.comwrote:
Yes. In my code I have
call.on("error", function (err) { console.error(err);});
My flow looks like this
- user gets redirected to a page with the peerjs id of the person they want to call
- user calls peer.call(id, localstream)
- call is established
- user refreshes page, disconnecting the person they wanted to call
- page tries to invoke peer.call(id, localstream) again. Console spews stuff about how it's totally connecting to the peer with that id
- user is stuck waiting for the call to connect until they decide to navigate away
I attach the listeners for all the possible events directly after making the call.
var call = peer.call(room, localStream);init_call(call);
init_call listens to "stream", "close", and "error" in that order.
— Reply to this email directly or view it on GitHubhttps://github.com/peers/peerjs/issues/197#issuecomment-44439680 .
Yes, I'm currently running it on Heroku (websockets enabled). I'll test that out and report back later. Thank you for the help!
Feel free to reopen this if you're still running into issues!
Whoops, sorry, I totally forgot about this. Basically, after being unable to reproduce my errors, I've tried destroying and creating a new PeerJS connection every time I want to do a call.
In my application, I noticed that if I tried to connect to a peer id that nobody was listening on anymore, the caller wouldn't get any sort of error or notification about it. This can leave my app in a strange state where it calls and just waits for the call to go through forever.