WebRTC and Asterisk: When It Goes Wrong

Like many things WebRTC is a complex stack of technology within Asterisk and also within the browser. The result of this is that to the best of our ability it doesn’t always work. The browser can change things, the network can stop things from working, the Javascript client may have an issue. This blog post is about breaking things down when you have a WebRTC problem to try to isolate where it may be.

1. Ensure You Are Running The Latest Asterisk

WebRTC fixes are continually put into Asterisk as it continues to evolve. If you are using an old version of Asterisk it is worth your time to try the latest version to ensure the problem you are experiencing has not already been fixed. This will also be required if you end up needing to file an Asterisk issue.

2. HTTPS Certificates

The first step is to make sure that you can contact the server you are using to get your HTML and Javascript. If you visit the URL and you don’t see it, then you should check to make sure that your browser has not rejected the HTTPS attempt due to the certificate. This also applies for the Websocket connection to Asterisk. If you are using self signed certificates you must accept them into your browser. For Firefox this means explicitly going to the HTTPS address for your Asterisk server. Failing to do so will result in the Websocket connection attempt to Asterisk failing and causing confusion.

3. Check Your Websocket Connection

When your Javascript client connects to Asterisk do you see anything in the Asterisk console? It should state that a Websocket connection has been accepted. If not then use the Developer Tools in your browser to look at the Network activity and see if (and where) it is attempting to connect. You may be getting bit by the HTTPS certificate problem as stated above. Your Asterisk may also not be listening on the port for HTTPS. This can be confirmed by using “openssl s_client -connect <asterisk IP>:<HTTPS port>” from a console. If this fails to connect then check your http.conf configuration and also look at the Asterisk console output when it starts. If it has a problem with a certificate it will state so.

4. Check Your ICE Negotiation

ICE is the technology used by WebRTC to find a viable path for communication between two things. Without this succeeding you will encounter a session where media doesn’t work. Looking at the ICE negotiation can be done by using Wireshark to capture the traffic or by increasing the Asterisk debug level (core set debug 5 and setting debug to go to somewhere in logger.conf). In the case of Asterisk it will flat-out state that ICE negotiation failed. If this occurs you’ll want to check the addresses being attempted to see if you think it should succeed. You can also use a TURN server to provide a relay to give a better chance that media will flow.

5. Check Your DTLS Negotiation

DTLS provides the security for WebRTC. Once ICE is negotiated then DTLS negotiation occurs where certificates are exchanged and the result is used to encrypt the media. On the Asterisk console you will see a message that the negotiation failed. You can also use Wireshark to capture the traffic and see the DTLS negotiation occur. If this fails then your DTLS configuration in Asterisk may be incorrect.

6. Check Your Javascript Console

The Javascript console in the browser can provide information if something goes wrong. This includes if the SDP given to the browser is not valid in some way or if there is a problem in the Javascript client code itself. This is a good place to look to potentially give yourself a hint of where to look elsewhere.

7. Check Chrome webrtc-internals

The Chrome web browser provides a very handy internal page called webrtc-internals accessible at “chrome://webrtc-internals” which provides information about WebRTC sessions. While in a call that is experiencing a problem you can bring it up and examine the ICE negotiation details as well as the individual media streams to see if media is being sent and received. If this seems to show that everything is good (media is flowing) then you may need to check your Javascript client to ensure it is correctly creating the needed HTML elements and using them.

8. Filing An Issue

If you still aren’t able to narrow things down and believe there is a bug in Asterisk itself you can file an issue on the Asterisk issue tracker. In doing so, though, you will be required to submit all the available information so we can figure out what is going on. The main information needed is as follows:

The Asterisk Console Output With Debug Enabled

A Wireshark Capture Of The Call

A Description Of The Scenario

A Description Of What Precisely Is Not Working In Your Scenario

The Version Of The Browsers Involved

The Version Of Asterisk In Use

Note that depending on your issue additional information may be requested.

I hope this helps to provide some guidance in figuring out what is going on when Asterisk and WebRTC goes wrong.

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.

About the Author

What can we help you find?