question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Healthy connections get destroyed during ice candidate negotiation

See original GitHub issue

Looks like this line here sometimes destroys even healthy connections!

https://github.com/feross/simple-peer/blob/cb73f00eca78054fe57047b2bf12eb2560f25ed3/index.js#L655

It happens when connection temporary fails and ICE is still negotiating candidates.

A little intro

  1. Connection in “failed” state stands for:

One or more of the ICE transports on the connection is in the “failed” state. (https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/connectionState)

But it actually also happen when iceConnectionState is “disconnected”.

  1. iceConnectionState in “disconnected” state means:

Checks to ensure that components are still connected failed for at least one component of the RTCPeerConnection. This is a less stringent test than “failed” and may trigger intermittently and resolve just as spontaneously on less reliable networks, or during temporary disconnections. When the problem resolves, the connection may return to the “connected” state. (https://developer.mozilla.org/en-US/docs/Web/API/RTCPeerConnection/iceConnectionState)

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: https://github.com/feross/simple-peer/blob/cb73f00eca78054fe57047b2bf12eb2560f25ed3/index.js#L676

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 offer this.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, because iceConnectionState 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!

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:11

github_iconTop GitHub Comments

1reaction
kk-007commented, Jul 26, 2020

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

1reaction
fippocommented, Feb 15, 2020

Most routers have timeouts on address mappings, which means the connection information in the server-reflexive ICE candidates expires.

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!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Reuse ICE candidates during webrtc re-negotiation
I am trying out an audio call after which I enable video. A new video stream is added to the existing Peer Connection...
Read more >
How NAT traversal works - Tailscale
In this post, we'll talk about how to establish a peer-to-peer connection between two machines, in spite of all the obstacles in the...
Read more >
Elderly exercisers have fewer broken bones after falls | Reuters
Older adults who exercise are less likely to fall, but if they do, they're also less likely to get hurt, a new analysis...
Read more >
SMALL BUSINESS ACT [Public Law 85–536 - GovInfo
in effect, an applicant for a business loan under section ... months in connection with any disaster referred to in section.
Read more >
BROKEN PROMISES: - U.S. Commission on Civil Rights
transmit our briefing report, Broken Promises: Continuing Federal Funding Shortfall for ... in health, education, and employment outcomes.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found