Can i set listenip and annoucedIp with domain

Now i set annoucedIP is ip of server and its work ok. But i need deploy mediasoup server to heroku. Can i set annoucedIp is url of heroku sẻver.

1 Like

That’s will may be work. But i want set it with domain for simple. Is it ok?

Have you read the doc about listenIp and announcedIp? Please say yes or no.

As a temporary hack we’re asking some public service for our IP (there are a lot of them) and fills it into environment variable if it is not set:

export MEDIASOUP_ANNOUNCED_IP=${MEDIASOUP_ANNOUNCED_IP:-$(curl -sSLf https://jsonip.com/ | jq --raw-output .ip)}

And then use it like this:

const transport = await this.#router?.createWebRtcTransport({
      listenIps: [
        {
          ip: "0.0.0.0",
          announcedIp: process.env.MEDIASOUP_ANNOUNCED_IP || "127.0.0.1",
        },
      ],
    // …

Of course this is not reliable (it adds one more failure point), so use with caution and replace with something else ASAP.

And no, you can’t use domain (or you need to resolve it to this server IP manually)

mmm, yes, you can use a domain here. Browsers (at least Chrome) support remote ICE candidates with a hostname instead of IP.

But if this hostname will be resolved to different IP than mediasoup server (e.g. if it points to some load balancer or just have multiple A-records), then things will break, right?

Sure, if you use a domain in announcedIp it’s your responsibility to make it have a DNS A or AAAA register properly pointing to your media server IP. I just meant that this is technically possible. When is this useful? no idea.