Transport Connection closes frequently

Hi!
my transport connection is close very frequently. I am not getting any error logs, just this function get called: transport.observer.on(“close”, fn()) . I am not sure how to provide you more info, I have open like 20k ports. but its still causing issues.

And why do you thing that opening 20k ports helps here?

transport.observer.on(“close”, fn()) is called when:

  • You call transport.close()
  • Or you call router.close()
  • Or you call worker.close()
  • Or worker dies due to a bug, but you did not report any crash.

Previously I had like 1000 ports and I was getting these problems. Then I opened 10K, just like in the demo code. and that fixed the issue, it kept working for 2-3 weeks. and now I am again getting this issue. so I thought I can try with increase the ports, but that did not fix it this time.
the first 3 scenarios are not true in my case, I am not calling these functions to stop it.
for third one, that is not true, because other people in room stay connected.

mediasoup Transports do NOT emit observer.on('close') event if there are no available ports.

If there are no available ports in the mediasoup-worker process, then router.createWebRtcTransport() will just fail and you won’t even have any transport instance in which you could listen for that close event.

My guess is that you are NOT closing transports when their associated peers leave the “room”.

I am closing transports. I know its hard to tell anything like that, I will debug more and get back if I can see anything useful. Thanks for your time.

I found where its causing the issue. Though its not related to mediasoup.

Webrtc transport is getting disconnected without any reason. Its Random, some times it does not happen for weeks but then it start happening. Any idea why this is happening? I not happening for one pc or one browser, different poeple are using it with different browsers.
Right now I was handling it by dropping the consumer/producer connection and recreating it? Shall I use restartIce instead?

I’m afraid you are mixing things. As I said, server side transport.observer.on('close') just triggers if YOU can transport/router/worker.close(). Period.

The problem is that your client side app may be listening for transport.on('connectionstatechange') events and, when “disconnected” you send a signaling to the server that calls transport.close().