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

72 views
Skip to first unread message

Yuan Ho

unread,
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

unread,
Dec 29, 2021, 2:24:03 AM12/29/21
to discuss...@googlegroups.com
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 https://github.com/webrtc/apprtc/pull/99/files 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 discuss-webrt...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/discuss-webrtc/c3c0a0be-6376-432c-ab5f-5ed71aa1d3f3n%40googlegroups.com.

Yuan Ho

unread,
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
Forward
0 new messages