addIceCandidate is blocking the event-loop
In my case there are times when it blocks the running of the entire node program sometimes for over 10 seconds. I discovered that the blocking of the event-loop comes from addIceCandidate and there may also be a block from setLocalDescription and setRemoteDescription I use polyfill to be compatible with the browser API, but I don't think it has anything to do with it.
i think maybe its happen when the remote candidate contains an IPv6 address. { candidate: 'candidate:995260933 1 udp 1677732095 ce81:ce81:ce81:ce81:ce81:ce81:ce81:ce81 54885 typ srflx raddr :: rport 0 generation 0 ufrag 5s6n network-cost 999', sdpMLineIndex: 0, sdpMid: '0' }
Is this a bug in node-datachannel or can it be handled through my code only? What is the technical reason for the problem?
I think it could be caused by the libjuice issue reported in https://github.com/paullouisageneau/libjuice/discussions/264: if DNS resolution for ICE servers fails, subsequent ICE calls for the same peer connection could block due to incorrect locking. It was fixed by https://github.com/paullouisageneau/libjuice/pull/267 and will be shipped alongside the next libdatachannel version.
But this happens specifically when adding this remote candidate. he dont need to deal with DNS resolution. Maybe it's because of invalid port number 0? raddr :: rport 0 (chrome browser generated this candidate like this to the nodejs)
But this happens specifically when adding this remote candidate. he dont need to deal with DNS resolution.
The issue could make ICE calls block, in particular setting remote description and candidates, because the ICE agent held a lock while resolving STUN/TURN servers in parallel which can take a while, especially in case of DNS failure.
Maybe it's because of invalid port number 0? raddr :: rport 0 (chrome browser generated this candidate like this to the nodejs)
This is fine, raddr and rport are allowed to be 0.
hi, last update v0.12.0 of node-datachannel seem that still not fix the issue.
any news about it?
Hello,
I'm still waiting for the next release of libdatachannel.
New version released here https://github.com/murat-dogan/node-datachannel/releases/tag/v0.20.0
Thank you for your patience!
New version released here https://github.com/murat-dogan/node-datachannel/releases/tag/v0.20.0
Thank you for your patience!
thank you very much and also for libdatachannel's team, i will check the new version and let you know if everything is working well.
unfortunately, seem like still in some cases addIceCandidate blocking the event-loop, but much less then before.
@Aviv1000 I can't reproduce. Do you have example code leading to addIceCandidate() blocking?
maybe was other problem in my code, until now i haven't seen blocking for a long time. I think it can be mark it as solved and closed. Thanks everyone 💯