No audio when running on Docker.

Hi everyone.
I dev mediasoup server base on GitHub - Dirvann/mediasoup-sfu-webrtc-video-rooms: A simple video conferencing example using the mediasoup sfu
When I run in localhost. everything is good.
But when I run server on docker(window 11 , Docker Desktop), no audio playing on receiver phone.
It seems like some rtc port is not working
Here is server log:

Produce {
  type: 'audio',
  name: 'testaccount1',
  id: '09497751-5456-471e-9a00-f92c12574a99'
}
Consuming {
  name: 'testaccount3',
  producer_id: '09497751-5456-471e-9a00-f92c12574a99',
  consumer_id: '1709d577-8021-4f23-acb3-43779763d85c'
}

Here is receiver client log:

 LOG  New producers [{"producer_account_name": "Account 1", "producer_id": "09497751-5456-471e-9a00-f92c12574a99", "producer_name": "testaccount1", "producer_socket_id": "wXI6aBPYOlvhUf1bAAAX"}]
 LOG  Closing consumer: 1709d577-8021-4f23-acb3-43779763d85c

But I can’t hear any audio playing.

Docker file:

FROM node:16

WORKDIR /app
# Install DEB dependencies and others.
RUN apt-get update \
	&& apt-get install -y net-tools build-essential python3 python3-pip valgrind
COPY package-lock.json .
COPY package.json .
COPY firebase.json .

RUN npm install

COPY src src
COPY ssl ssl

EXPOSE 3016
EXPOSE 10000-10100

RUN npm i -g nodemon

CMD npm start

Config.js:

const os = require("os");
// const ifaces = os.networkInterfaces();

function getListenIps() {
  const listenIps = [];
  if (typeof window === "undefined") {
    const os = require("os");
    const networkInterfaces = os.networkInterfaces();
    const ips = [];
    if (networkInterfaces) {
      for (const [key, addresses] of Object.entries(networkInterfaces)) {
        addresses.forEach((address) => {
          if (address.family === "IPv4") {
            listenIps.push({ ip: address.address, announcedIp: null });
          } else if (address.family === "IPv6" && address.address[0] !== "f") {
            /* ignore link-local and other special ipv6 addresses.
             * https://www.iana.org/assignments/ipv6-address-space/ipv6-address-space.xhtml
             */
            listenIps.push({ ip: address.address, announcedIp: null });
          }
        });
      }
    }
  }
  if (listenIps.length === 0) {
    listenIps.push({ ip: "127.0.0.1", announcedIp: null });
  }
  // console.log(listenIps);
  return listenIps;
}

module.exports = {
  // listenIp: "192.168.1.12",
  listenPort: 3016,
  sslCrt: "../ssl/cert.pem",
  sslKey: "../ssl/key.pem",

  mediasoup: {
    // Worker settings
    numWorkers: Object.keys(os.cpus()).length,
    worker: {
      rtcMinPort: 10000,
      rtcMaxPort: 10100,
      logLevel: "warn",
      logTags: [
        "info",
        "ice",
        "dtls",
        "rtp",
        "srtp",
        "rtcp",
        // 'rtx',
        // 'bwe',
        // 'score',
        // 'simulcast',
        // 'svc'
      ],
    },
    // Router settings
    router: {
      mediaCodecs: [
        {
          kind: "audio",
          mimeType: "audio/opus",
          clockRate: 48000,
          channels: 2,
        },
        {
          kind: "video",
          mimeType: "video/VP8",
          clockRate: 90000,
          parameters: {
            "x-google-start-bitrate": 1000,
          },
        },
      ],
    },
    // WebRtcTransport settings
    webRtcTransport: {
      listenIps: getListenIps(),
      maxIncomingBitrate: 1500000,
      initialAvailableOutgoingBitrate: 1000000,
    },
  },
};

Here is Docker run command:

docker run -d -p 3016:3016 -p 10000-10100:10000-10100/tcp -p 10000-10100:10000-10100/udp -it  walkie-talkie-rn-server

Thank you.
Vu.

You are probably missing something in configurations. We have to use proper server public ip in “announcedIp” normally on server and I think this should be the case for docker as well, haven’t tried. Apart from that you must have all the tcp/udp ports range enabled, you provided to mediasoup, on your server. Go to chrome://webrtc-internals and inspect your peer connections with the server, that will tell you many things. Below topic have some similar issue with docker and there are many others:

1 Like

Hi, I dev only on ReactNative(android), how can I check webRTC connect?
-Docker in my pc, I change announcedIp with public IP.
-I deploy docker image to aws ecs fargate.
Nothing change in both case.
Any guide for this. Many thanks.
Vu

chrome://webrtc-internals will not be possible on mobile, you can print the ice candidates received from server in console to see what you are getting, you will be able to verify the missing thing. Do make sure to open the relevant tcp/udp port range on server which you are providing to mediasoup otherwise things will not work. I haven’t used docker, will not be able to help with the docker config, but I have found plenty of topic on this platform related to docker, have you checked them?

Thank you,
I have add { ip: “0.0.0.0”, announcedIp: “192.168.1.14” } to listenIps. It already work in my pc. (192.168.1.14 is local ip of my network).
I’m trying to find the public ip of ecs fargate instance to reaplace announcedIp.
I have read and tried the ways on the discussion group but it didn’t work for me.
Any way, thank you for your help.

Ok double check the ports on server, on local ports cause no issue.

yeah, I changed publicIpv4Address of fargate ecs to announcedIp. Great work :))

Great :+1: