Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to determine if TURN server is being used (WebRTC)?

I want to gather stats on the number of users having to fallback to TURN servers. Thus is there a way to find if a RTCPeerConnection is using a TURN server instead of "directly" communicating with a remote peer?

I've tried using pc.getStats() but that only gives me an object with a size property.

like image 210
user8380672 Avatar asked Sep 13 '25 07:09

user8380672


1 Answers

You want to use getSelectedCandidatePair. This will return the local/remote candidate that is being used. Each candidate will have a type host, srflx, prflx or relay. relay means it is using TURN.

Make sure to check both candidates. It is possible that both pairs are TURN (or maybe just one)

like image 169
Sean DuBois Avatar answered Sep 14 '25 20:09

Sean DuBois