-
-
Notifications
You must be signed in to change notification settings - Fork 981
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Healthy connections get destroyed during ice candidate negotiation #590
Comments
Can you try to replicate this between Chrome/Chrome Chrome/Firefox Firefox/Firefox? |
Ok! This time I have different errors though. So for chrome(initator) <-> chrome connection the error is: The state right before the fail:
For chrome(initiator) <-> safari the error is:
The state before fail:
I saw both these problems in chrome/safari pair though, as per issue. |
I've made a fork with a condition for this._connected welldan97@7a8cbe2 This works for me, so far. I bet this would be also better for many cases. But probably it doesn't cover all the cases good enough: now I think that even once connected it could reach these strange recoverable states. |
The latest information I know is that SDP is only valid for about 30 seconds if the spec didn't change. So you can't really store it and if you wait for too long connection will fail and this is expected. @t-mullen do you remember why those were added? It is possible there was some kind of quick in one of the browsers that it was necessary to fail the whole connection. Usually though this will happen automatically and you can retry quickly, so shouldn't be a big issue. But the problem is interesting nonetheless. Also did you verify that connection actually works, meaning you can send audio, video or other data over it? |
These states are equivalent. The reason we listen for both is due to a bug in Chrome causing the
Are you sure the connection is usable when |
ICE failures are sometimes recoverable using an ICE restart, a procedure not implemented in simple-peer yet. See #579
If you can confirm the peer datachannel and any audio/video streams still work after ICE failure, I can look more into this. |
@nazar-pc So today I've made some experiments. Unfortunately this time 4g Mac could not connect to wifi Mac at all. That was strange. Then I've tried to connect to my friend in Russia. So the set up was like this: Initiator: Me(Chrome, Macbook, Portugal) So we tried several experiments, each time same scenario:
These are the results: X/delay - result: ≈0 min - success, I've tried each delay only once. Another thing I've tried is waiting before sending the offer. Thanks for inputs @t-mullen . I'm happy to learn more about WebRTC, and simple-peer So regarding this, to summarize. According my experiments Peer.js kills connection in around 15 seconds, when the connection officially dies. But if peer.js would not kill a connection,a user could still recover connection if they connect within 1 min. And that's a huge difference when one send signaling manually via messenger! I see that with signaling server it's a no issue at all. But, I'm building an experimenting project, and I want to see how far the p2p can be pushed with WebRTC. I want to have an ability to establish connection manually - this way one need even less servers. I think that could be useful to other users as well, may be as opt-in. What do you think? |
Having long delays in signalling is not something that can be done reliably. The ICE candidates contained in the signal messages are time-sensitive. The reason for this isn't due to simple-peer or even WebRTC, but your router. Most routers have timeouts on address mappings, which means the connection information in the server-reflexive ICE candidates expires. https://en.wikipedia.org/wiki/Network_address_translation The only guarantee the spec gives you is this (keep in mind not every router follows the spec).
Although it would be nice if we could just connect whenever we wanted with an IP and port, the reality of NATs means that's impossible in the general case. |
WebRTC implementations should periodically ping the STUN server to keep the mapping open, see https://tools.ietf.org/html/rfc5389#section-6. If that isn't the case, please file a bug against the implementation! |
I'm also experiencing the issue that @welldan97 has laid out. If I wanted to ping the STUN server in the simple-peer implementation, how would I do so? |
it looks funny but i have the same issue and i solved it by changing internet connection. when i switch to mobile data from a broadband project run well and when i again switch back to broadband it gives that error. my project: https://github.com/kk-007/webrtc-video-call |
Looks like this line here sometimes destroys even healthy connections!
simple-peer/index.js
Line 655 in cb73f00
It happens when connection temporary fails and ICE is still negotiating candidates.
A little intro
But it actually also happen when iceConnectionState is "disconnected".
And what I've realized right now, is that actually even "failed" iceConnectionState can be recovered. So may be this line could be also somehow improved as well:
simple-peer/index.js
Line 676 in cb73f00
How to reproduce
So I used chrome & safari browsers. And checked connection from 2 macbooks, one connected to 3G another to wifi. I pass signals(offers/answers) manually via messenger
I've used turn& stun servers from Twilio as configuration
Ok. So first I create Peer with
initiator:true, trickle: false,
on first mac. I get offer with candidates.On another mac then I create Peer with
initiator: false, trickle: false
. And then I pass offerthis.peer.signal(offer)
. If I'll pass answer back to initiator fast enough, connection get created. But I wait for around 15 seconds & then connection get destroyed, becauseiceConnectionState switches to "disconnected" or to "failed". And that's what is fishy.
The interesting thing is that if I comment out mentioned lines then I am able to create connection even when it's in "failed" state.
Thoughts
So this makes me think that "failed" or "disconnected" states for iceCandidates and "failed" state for connection itself don't mean too much. It's not a failure yet, I guess, since it can be reestablished so easily, it's more "on hold" type of state.
I'm not really sure how the issue can be fixed, though since I'm pretty new to WebRTC myself. And all these states are confusing. It needs further experimentation
Thank you!
The text was updated successfully, but these errors were encountered: