How to know if connection to turn server is using tcp or udp

Skip to first unread message

Yuan Ho

Dec 29, 2021, 2:16:39 AM12/29/21
to discuss-webrtc
To cope with some strict firewalls, we configure both udp and tcp transport to the turn server.

    this.d_server = {
      "urls": ["turn:turn." + VENDOR.DOMAIN + "?transport=udp",
                "turn:turn." + VENDOR.DOMAIN + "?transport=tcp"],
      "username": undefined,
      "credential": undefined

Now we want to gather statistics about how many use udp and how many use tcp.

However, this information is not available in the candidate object.

Is there any way for the javascript to know whether it is connecting to turn server using udp or tcp? Thanks very much.

Philipp Hancke

Dec 29, 2021, 2:24:03 AM12/29/21
the information is not available on the icecandidate object directly but you can either
1/ use getStats and look for the relayProtocol property on the local candidate object
2/ do a ">> 24" on the candidate priority. In chrome and safari that will result in 2 for turn/udp, 1 for turn/tcp and 0 for turn/tls. Firefox is slightly different and uses 5 for turn/udp and 0 for both tcp and tls if I recall correctly.
See for a bit dated code for the second option.


You received this message because you are subscribed to the Google Groups "discuss-webrtc" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

Yuan Ho

Dec 30, 2021, 4:42:00 AM12/30/21
to discuss-webrtc
I use method 1 and it works! Thank you very much!
Reply all
Reply to author
0 new messages