ejabberd: Announce external STUN/TURN over XMPP (XEP-0215)

Since Conversations release 2.8, audio and video calling is supported. This feature is an amazing addition simply amazing makes Conversations equivalent to other major chat apps.

To get this feature working however, you need a server which has STUN and TURN services exposed and also announces them via XMPP (XEP-0215), so Conversations can pick up the configuration and use them.

There is a nice guide on how to set up Prosody and coTURN, and the author of Conversations posted some minimal instructions for using ejabberd’s built-in STUN/TURN server, but I couldn’t figure out how to announce an external STUN/TURN server via ejabberd.

First, I was looking into mod_disco, which is ejabberd implementation for service discovery. Unfortunately, this led me nowhere, since it only implements XEP-0030 (“Service Discovery”), not XEP-0215 (“External Service Discovery”).

This module adds support for XEP-0030: Service Discovery. With this module enabled, services on your server can be discovered by XMPP clients.

It turns out that since release 20.04 ejabberd has a new module to handle exactly this functionality: mod_stun_disco.

This module allows XMPP clients to discover STUN/TURN services and to obtain temporary credentials for using them as per XEP-0215: External Service Discovery.

Since ejabberd has a built-in module for STUN and TURN services, you can either use that one, or use an external STUN / TURN server such as coTURN.

My coTURN server is setup as described here. The following configuration assumes your STUN and TURN server are running on the default port (3478) and are not using the encrypted variants (stuns and turns). Furthermore, it assumes the default transport protocol is UDP, which is true in most cases.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
modules:
  mod_stun_disco:
    secret: y0ur-$hared-$3cR3t-here
    services:
      -
        host: example.com
        type: stun
      -
        host: example.com
        type: turn

If you have a typical STUN / TURN server setup (e.g. for Jitsi Meet or Nextcloud Talk), your STUN server allows anonymous login and your TURN server requires authentication. That’s what the secret shown above is used for.

For the detailed setup, please refer to the ejabberd documentation on mod_stun_disco.

I hope this helped you set up your ejabberd server for audio and video calls with Conversations. Happy calling!