/
Testing connection to STUN server

Testing connection to STUN server

When troubleshooting WebRTC connectivity issues, it is helpful to confirm whether or not the client can successfully reach the necessary STUN server. Having a proper connection to STUN is a critical component to advertising your public IP address and chosen port to our webRTC resources; especially in the case of NAT. If you’d like to learn more about STUN, this article is very informative.

This guide provides a quick set of instructions to validate reachability of a STUN server. There are two methods of testing; 'Using the Browser Console” and the “webrtc.github.io” method.

Sharpen webRTC leverages the Google STUN servers accessible via stun.l.google.com:19302. The methods below test against the same endpoint Sharpen uses.

webrtc.github.io

The following tool is not managed by Sharpen, so it should be noted that its usefulness may change.

  1. Navigate to Trickle ICE (webrtc.github.io)

  2. Click the “Gather Candidates” button

  3. Evaluate the results

  4. If you do not see a reflexive reference to your public IP address, then you’re having issues connecting to the Google STUN server.

Using the Browser Console

  1. Open a chrome web browser

  2. Open the inspector (right-click>inspect)

  3. Choose the ‘Console’ tab

  4. Paste in this block of code

    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));
  5. Press enter

  6. Observe the response

Log errors:
In most of the cases, even if the required path is open, you will find a STUN host lookup received an error. Chrome tried to look up the IPv6 DNS record for server and got an error in that process. This is expected. However, it may still be accessible through the IPv4 address.

A response should look something like this if it worked

 

 

 

Related content

Handling Voicemail in Sharpen Q
Handling Voicemail in Sharpen Q
Read with this
Using a specific webRTC connection
Using a specific webRTC connection
More like this
Sharpen Q: Internal Controls
Sharpen Q: Internal Controls
Read with this
Network Requirements
Network Requirements
More like this
Disabling Network Adapters
Disabling Network Adapters
Read with this
WebRTC Internals Logs
WebRTC Internals Logs
More like this