Hey guys, I get this error after a while: [no more available ports [transport:udp, ip:’0.0.0.0’, numAttempt:101] even though I close transports on disconnect.
You need to close the transports you create in mediasoup side, that’s all. I don’t know if you are doing something wrong in your code, but the theory is easy: If you create transports associated to a “user” and the user disconnects, you must close the transports you created by calling close() on them. That’s all.
When I close consumer transport that was created for client that disconnected then ports are free but sometimes I get an error: Error: Consumer not found in mediasoup/lib/Channel.js:199:37. What does have to be done before I can close consumer transport?
I also have a set of remote clients for each client that I loop through and close all consumers with id of disconnected client.
for (const [socketId, set] of this.consumerSets.entries()) {
for (const [remoteId, consumer] of set.entries()) {
if (remoteId === socket.id) {
consumer.close();
set.delete(remoteId);
console.log("Deleted consumer of", socketId, "for", remoteId);
}
}
}
if (consumerTransport)
consumerTransport.close();
I don’t know what a “consumer transport” is. Anyway you are talking about “closing transports” then you show code that closes consumers. I don’t follow, sorry.
I just follow examples and there is consumer transport. It is created for client when they connect and want to consume all other clients. My previous message shows code that closes consumers.
This is a message from the worker process. Probably you are closing consumer after its producer has been closed (along with all associated consumers). Just close the consumer transport. There is no need to close consumers manually when the transport is closed.