STUN / TURN server


I was working with peer to peer technology before and in the production mode i needed to configure the iceServers: [ ] that contain a Stun and Turn servers to ensure best connectivity between peers.

do i need to use this iceServers in the Mediasoup use case ?

if yes, please, where could i integrate my servers? (stun/turn iceServers: [ ])

1 Like

As far as I know you don’t need any.
Stun servers are used to find the ip of the two parties to try to have a direct connection. With mediasoup you already know the IP of your server so the browser knows exactly where to connect to.
Turn servers are used as a relay if direct connection isn’t possible. With mediasoup you already have a direct connection to the server from the browser.


@Dirvann I Got you now and the answer was on my question, I was using a peer to peer tech.
Thank you so much.

good job in the Github.

1 Like

no more available ports transport:udp, ip:’’, numAttempt:101 what does it mean ? i notice that frequence error many times when i tested the library? is that mean the server reacht he max consumer and producer number ?

It means that:

  1. You are not closing mediasoup Transports once their clients disconnect, or
  2. You are not opening enough ports.

This is a bug in your app logic/code.

hello, how can I know the total number of producers and consumers on my server or on my mediasoup extention ?

You create them so you must know.

Also please don’t use an existing thread for unrelated questions.

1 Like

If a client has blocked UDP ports, TURN server comes to the rescue, so data would be sent through TCP, with a bigger delay ofc, but it covers more clients.

I found this thread and comments from @ibc very helpful regarding STUN/TURN:

In many of the historical posts from @ibc he pointed out that MediaSoup uses ICE-LITE, “meaning that it does not require ICE candidates from clients but, instead, will wait for RTP in its open ports to know the client’s remote IP, port and transport protocol (UDP or TCP).”

Another thing I have read that may be useful here: configuration using port 443 is a way to get around restrictive corporate firewalls, if necessary. From @ibc in this post:

For worst network cases you should have your TURN server listening into TLS port 443 with a proper TLS certificate. Since some networks (WiFi in hotels and so on) block traffic other than 80 and 443, you’d rather have TURN listening in TLS 443 of public IP_A and your HTTP/WS signaling server in TLS 443 of public IP_B.

One thing I am also investigating, rather than eliminate stun/turn entirely, is if there is any benefit to installing Coturn alongside MediaSoup, even on the same server, and using it for normalizing client connections and managing them and then MediaSoup for the SFU functions. This and port 443 is mentioned in a post at medium (google: WebRTC pro-tips @ Medium – I am limited in links in my post as a new member)

If you’re using an SFU or MCU, consider running TURN along-side your software, and forcing everyone to relay through TURN. It’s sixes this way and can actually simplify a few things.