Hi, mediasop 3.14.0 has been released with portRange in TransportListenInfo.
Details
New optional portRange field of type TransportPortRange has been added in TransportListenInfo, so it’s available in router.createWebRtcTransport(), router.createPlainTransport(), router.createPipeTransport() and worker.createWebRtcServer() methods.
If portRange is given, then a free random port in that range (and given ip and protocol) will be chosen.
This feature deprecates worker ports range (rtcMinPort and rtcMaxPort in WorkerSettings given to createWorker() method). Rationale is that it doesn’t make any sense to have a unique port range for different listening IPs (for example: an app may want to use different port ranges for public connections (public internet) and private connections (private network).
If the WebRtcServer is designed to work with a single port per worker (without need to open large ports range in the firewall), why would someone need to use a portRange in this case?
Yeah, got it, but why would one choose to specify a portRange in the ListenInfos of a WebRtcServer when typically a single port should be sufficient, especially in scenarios involving multiple workers each with its own WebRtcServer?
Edit: Maybe for Load Distribution: By defining a range of ports rather than just one, the WebRtcServer gains the ability to distribute incoming connections across multiple ports. This can help in balancing the load more efficiently, especially in high-traffic environments.
You create 8 workers and in each worker you create a WebRtcServer with portRange: { min: 20001, max: 20008 }.
All ports will be used and you don’t need to care about assigning fixed ports.
Not sure what you mean. portRange is not about opening many ports. It’s about opening a single port in the given port range. Which one? Any available random port.
hi, If one port is given instead of port range then only that port will be used by all workers, and mediasoup will not have any issues dealing the packet with that single port?
Perhaps it’s necessary to also revisit this section in the mediasoup demo. Here, it appears that ports are being allocated dynamically without consideration for whether the portRange is set in the WebRtcServerOption listenInfos.
Below is a suggested improvement:
if (!listenInfo.portRange)
{
listenInfo.port += portIncrement;
}
In config.js we don’t pass any portRange to WebRtcServer but a single port. I understand your point but honestly nobody should take mediasoup-demo as a reference app.