[libnice] Force an external address (srflx) candidate?

Stuart Marshall stuart at seelye.net
Wed Oct 14 21:22:03 UTC 2020

I’ve been wanting something like this too.

We have a WebRTC server that similarly has a stable external address (which is not easily visible to libnice). The server is never on the same local network as the client. So the whole ICE negotiation dance is slow and includes many wasteful tests.

In contrast, the ICE candidates emitted by Chrome are stunningly few and precise. I understand that the ICE protocols and the libnice implementation were/are meant to be general case. But they miss obvious efficiencies that can be provided by additional external information. STUN servers facilitate some of that additional information, but introduce a dependency and more latency.

My knowledge of libnice internals is not great, but I kind of wish we could

  1.  Feed some particular IP candidate addresses to it,
  2.  Tell it to skip a bunch of other candidate generation and testing
I believe there’s a compilation flag to turn of ipv6, but I haven’t seen other mechanisms to disable some of the candidate generation and testing.

Juan, to further answer your question: we’re using libnice for our server. However, I had to upgrade the libnice to a private build from the tip of libnice master. The default libnice on Ubuntu 18.04 had a bunch of bugs that prevented ICE negotiation from working well. The latest libnice seems to work well (albeit a bit slowly), but you may not be able to use the standard ones that come with your distro. I haven’t checked the version of libnice in Ubuntu 20.04. I think it was updated, but not sure if it has all the recent(ish) bugfixes.


From: nice <nice-bounces at lists.freedesktop.org> on behalf of Juan Navarro <juan.navarro at gmx.es>
Date: Wednesday, October 14, 2020 at 7:11 AM
To: "nice at lists.freedesktop.org" <nice at lists.freedesktop.org>
Subject: [libnice] Force an external address (srflx) candidate?


I'd like to allow setting a static external IP address to my WebRTC SFU server config, and have libnice generate a "fake" server-reflexive candidate without needing STUN or TURN. Is this possible to do with libnice?

This is useful for cloud deployments where the server has a well known address, to skip the need for STUN on the server and also minimize the time needed for ICE. At the same time, any WebRTC peer would transparently work by receiving the fake srflx candidate, thus knowing where to connect with the server. This is an important one for me: not needing to touch anything else about the signaling or the implementation at the client.

To be honest I already have this feature working (see WebRtcEndpoint.setExternalAddress<https://doc-kurento.readthedocs.io/en/latest/_static/client-javadoc/org/kurento/client/WebRtcEndpoint.html#setExternalAddress-java.lang.String->) but it is a VERY ugly hack, which modifies _all_ candidates to replace their IP address with the external one specified in this setting. This works, because remote peers receive then all those host candidates with the correct IP, and they are able to connect with the server. But I'd like to have a "cleaner" solution, if there is one for this scenario. So I thought that a better thing to do would be to tell libnice to forge a srflx candidate.

BTW, what are people doing for this? I think letting a server know of its own external address is a pretty common thing (e.g. "external-ip" setting in Coturn).

Thanks and regards,

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.freedesktop.org/archives/nice/attachments/20201014/d430a047/attachment.htm>

More information about the nice mailing list