mediasoup v3 with Docker

3.2k views Asked by At

Im trying to run an 2 WebRTC example(using mediasoup) in docker

I want to run two servers as I am working on video calling across a set of instances!

My Error:

Have you seen this Error: createProducerTransport null Error: port bind failed due to address not available [transport:udp, ip:'172.17.0.1', port:50517, attempt:1/50000]

I think it's something to do with setting the docker network?

docker-compose.yml

version: "3"
services:
  db:
    image: mysql
    restart: always
  app:
    image: app
    build: .
    ports:
      - "1440:443"
      - "2000-2020"
      - "80:8080"
    depends_on:
      - db 
  app2:
    image: app
    build: .
    ports:
      - "1441:443"
      - "2000-2020"
      - "81:8080"
    depends_on:
      - db 

Dockerfile

FROM node:12

WORKDIR /app
COPY . .

CMD npm start
3

There are 3 answers

0
Dirk V On

It sais it couldn't bind the address so it could be the ip or the port that causes the problem.

The ip seems like it's the ip of the docker instance. although of the docker instances are in two different machines it should be the ip of the server and not the docker instance. (in the mediasoup settings)

There are also ports of the rtcp connection that have to be opened in the docker instance. They are normally also in the mediasouo config file. usually a range of a few hundred ports that need to be opened.

0
brndusic On

If you are running mediasoup in docker, container where mediasoup is installed should be run in network mode host.

This is explained here:

How to use host network for docker compose?

and official docs

https://docs.docker.com/network/host/

Also you should pay attention to mediasoup configuration settings webRtcTransport.listenIps and plainRtpTransport.listenIp they should tell client on which IP address is your mediasoup server listening.

0
Md Azharuddin On

You should set your rtc min and max port to 2000 and 2020 for testing purpose. Also you are not forwarding these ports I guess. In docker-compose use 2000-2020:2000-2020 Also make sure to set your listenIps properly.