When troubleshooting WebRTC connectivity issues, it is helpful to confirm whether or not the client can successfully reach the necessary STUN server. This guide provides a quick set of instructions to validate reachability. There are two methods of testing; 'Using the Browser Console” and the “webrtc.github.io” method
Using the Browser Console
Open a chrome web browser
Open the inspector (right-click>inspect)
Choose the ‘Console’ tab
Paste in this block of code
Code Block const iceServers = [ { urls: 'stun:stun.l.google.com:19302?transport=udp' }, ]; const pc = new RTCPeerConnection({ iceServers }); pc.onicecandidate = (e) => { if (!e.candidate) return; // Display candidate string e.g // candidate:842163049 1 udp 1677729535 XXX.XXX.XX.XXXX 58481 typ srflx raddr 0.0.0.0 rport 0 generation 0 ufrag sXP5 network-cost 999 console.log(e.candidate.candidate); if(e.candidate.type == "srflx"){ console.log("The STUN server is reachable!"); console.log(` Your Public IP Address is: ${e.candidate.address}`); } }; pc.onicecandidateerror = (e) => { console.error(e); }; pc.createDataChannel('stun-test'); pc.createOffer().then(offer => pc.setLocalDescription(offer));
Press enter
Observe the response
...
A response should look something like this if it worked
...
Alternatively, we can test STUN server connectivity through the tool below.
webrtc.github.io
The following tool is not managed by Sharpen, so it should be noted that its usefulness may change.
Navigate to Trickle ICE (webrtc.github.io)
Click the “Gather Candidates” button
Evaluate the results
If you do not see a reflexive reference to your public IP address, then you’re having issues connecting to the Google STUN server