TURN usage in Mediasoup

Hi Team,

When we use webrtc for a peer to peer connection we specify all our TURNand STUNservers and gather all the ice candidates available. Depending on latency and few other parameters webrtc decides which candidate to use, Please correct me if i am wrong. It may happen that the prefered candidate is a TURN over UDP/TCP.

Coming to my question, How TURN usage comes into picture when using mediasoup? A documentation on this would be really helpful:sweat_smile:

Thanks in Advance,

A TURN server is a relay node independent from mediasoup. It sits between the client and mediasoup when it comes into play and relays the media from one to another.

What is the specific question?

mediasoup will not even realize if a client is using a TURN server (other than the media source IP). And mediasoup-client exposes an API to set TURN servers if desired, so no much to document here. It is a completely common TURN usage.

Hi Team,

Thanks for your response.

I will look into the mediasoup-client exposed api to set the TURN servers.

Hi Team,

Tried using the TURN server with the mediasoup-client, set the iceServers property while calling the device.createSendTransport(transportOptions); in the transport options. My client is in a corporate network where it is behind a firewall and direct media transfer is not possible to the mediasoup over UDP(since UDP ports are blocked). Mediasoup server is hosted at Google cloud having private ip as and announceIP as

For a client who is not behind a firewall everything works fine but for a client behind firewall in a corporate network is not able to send the media streams to the mediasoup server. There is one icecandidate generated as shown in the snapshot:

If we provide TURN servers in the iceServers property how will the iceCandidate be generated in the sendTransport or receiveTransport ? Will it prioritize the use of the ice candidates received from the socket.request(createProducerTransport) function or not?
Is it possible to produce new iceCandidates dynamically? The Mediasoup Servers are also behind a firewall but we have provisioned open UDP/TCP ports between 10000-14000, according to the mediasoup config of rtcMin and rtcMax port range.

I’m afraid you must learn how TURN works. You are making random questions that are not based on real usage and behavior of TURN scenarios. The TURN ice candidates are produced by the PeerConnection if you properly setup the TURN settings and the client can indeed connect to the TURN server to allocate an address and port (that may be over UDP, TCP or TLS with a proper&valid TLS certificate).

So check your TURN configuration and wonder why your client cannot get TURN ice candidates from it. However this is out of the scope of mediasoup and this is not a forum about common WebRTC issues.