no more available ports [transport:udp, ip:'0.0.0.0', numAttempt:101]

I was working on an architecture and in a moment that message appears on the server-side for my app that announces that the UDP ports are blocked or attempt his max. 101 !?

is that mean the media soup server couldn’t handle more than that number and I have to upgrade the server performances ? or the problem is no my work itself?

thank you!

The log means that there is no free bindable UDP port in the range you provided to the worker. Meaning the ports are not bindable or already in use. You need to provide a wide enough port range to the worker to avoid an early exhaustion.

In any case, check such ports usage in your system by the time you get the log.

Or you may be not closing server side transports so ports remain open.

Does that mean even though with powerfull CPU mediasoup can only handle number of users per server due to limitation in port. i recently faced this problem in prod. even though I was using wide range of port. I was showing off that mediasoup based voice server can handle any number of people but then suddenly server started giving this error.
mediasoup:ERROR:Channel [pid:85251 RTC::PortManager::Bind() | throwing MediaSoupError: no more available ports [transport:udp, ip:'0.0.0.0', numAttempt:2]

but also I read in docs that even though we can fire up new ec2 instance when I create a transport to that server it binds the port.so I end up with limited users per port. :frowning: is there any workaround for this ?. I don’t care about performance for now as I am using very low resolution and very low frame rate. i just want lots of users on single server more than 50,000 at least.

Either you are providing less number of ports or are not properly closing them after using. What is the port range your provide to createWorker method?

Actually i am using 40000 to 49999. but I just wanted to see how my ec2 performs in large audience. but CPU was still at very low which was good but as soon as another member arrived in one the space mediasoup start giving warnings. I am closing all the ports. just that my audience was very large. we were doing a local community conference were large number of people joined in conference room.

so started looking into docs. and then I realized that transports are binding to ports.
but I wanted to have large number of people with different rooms in one instance so that I don’t have to code for router.pitetorouter to another worker.

These ports can only handle around 9999 transports, you need to provide more ports to handle more transports or you can try new version of mediasoup which uses ports per worker rather than per transport, you can read more about it here:

Oh Is that so . i am using 3.10.3. I have to look into this. so what is the ideal solution here? because let’s say 0 to 65535 ports are there then also per worker we can only supply to 65535 users only. which is very low

No, 1 worker uses 1 port. And on 1 worker you can handle n number of consumers based upon the core capacity of your CPU as each worker runs on it’s core. So if 1 core of you cpu can handle 1500 consumers and you have 32 cores which means you should create max 32 workers then below is the math:

CPU = 32 cores
1 worker = 1 core
1 worker = 1500 consumers
32 workers = 1500 * 32 = 48000 consumers

So your CPU with that capacity can handle around 48000 consumers. But in reality actual number of consumers can be lower than this because of the piping, if you are doing, and some other stuff of your server.

You can calculate the number of consumers in your call session and see the max number of users your CPU can handle

Your server can’t handle 65535 users, this should be out of the limit of your server. You need multiple servers to handle that many users.

@zaidiqbal this is awesome. I did upgrade mediasoup 3.10.3 but didn’t checked what you just shared me. i coded that thing and even with one port open I was managed to work with 5 different users sharing video and audio . this is very awesome. now I can have power full server and mediasoup will do the rest @ibc thanks for amazing cost effective feature. no need for extra worker at least for now.

@zaidiqbal as I said I don’t have requirement for high-resolution. very low res low frame rate. but large audience

@zaidiqbal you don’t so many worker. all you have to do is one worker per router then just create room and every room will have common worker and router then just make a Map object for list of users. mediasoup will do the rest. let me know if you need any help.

Awesome :+1:

No brother, with one worker for all rooms you will only use one core of your cpu while the rest of the cores are just sitting free there. With such large audience you need multiple workers per room.

You can find more information on my topic here:

The topic was open 2 years ago, why would you guys re-open it. Stop…

That is @robokishan fault :running_man: :grinning:

Question was relevant and it was showing first in google search so i posted over here instead of creating new one. so people can find relevant answer