Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.


Tutorial Overview


This tutorial demonstrates basic WebRTC support and functionality


within Asterisk




 Asterisk will


be configured to support a remote WebRTC client,



It is hard to design a tutorial that applies to every environment, so remember the following:

This tutorial written using Debian Squeeze 6.0.5, Asterisk 11.8.0-rc1 and Asterisk's chan_sip channel driver.

We assume you are a little familiar with Asterisk, and have an Asterisk installation available via a public IP address, and control of the firewall in front of it. (you do have it fire-walled right?)

The SIPML5 client will be accessed via Chrome and is assumed to be behind NAT.


In newer versions of Chrome and Firefox (and others) DTLS-SRTP is mandatory. This means you must generate certificates for Asterisk to be able to use. See: Secure Calling Tutorial

Get dependencies

Install a variety of essential dependencies to make sure we get them. Plus install the uuid-dev package that isn't included in the Asterisk 11 install_prereq script.

No Format
sudo apt-get install build-essential libncurses5-dev libxml2-dev libsqlite3-dev libssl-dev libsrtp0-dev uuid-dev

Then go to your Asterisk source /config/scripts/ directory and run the install_prereq script to get everything else that is needed.

No Format
sudo ./install_prereq install
sudo ./install_prereq install-unpackaged

Build Asterisk with support for WebRTC

 Using menuselect make sure Asterisk will build with res_http_websocket, res_crypto and chan_sip.

In the Asterisk source directory:

No Format
./configure && make menuselect

 After verifying things are as needed in menuselect, then build and install Asterisk

No Format
make && make install && make samples

Configure Asterisk

Now we need to configure the various Asterisk components necessary for WebRTC support.

I always recommend backing up your current .conf files and using clean, blank text files for trying out a tutorial like this. Especially if you are new to Asterisk.

Configure http.conf

No Format

You need to configure Asterisk's builtin HTTP server. You could use whatever bindport or bindaddr you want, but make sure you adjust the other configurations to match. This is the port and address that res_http_websocket and chan_sip will talk over when using a WebSocket transport.

Configure rtp.conf

No Format

Configure the range of ports to use for RTP media, and we can set icesupport=yes (although the default in recent versions of 11 is now "yes") to enable support for the ICE protocol in general. We also set the address of the STUN server to use here. We use Google's STUN server which should work for just about everyone.

Configure sip.conf

No Format
realm= ;replace with your Asterisk server public IP address or host


There is already a lot of content on the wiki and in the sip.conf sample file that explain the options here. The key options for WebRTC support and ICE support are explained at this link for WebRTC and this one for ICE.


Though this page is written to Asterisk 11 and chan_sip, an example for setting up a PJSIP endpoint in Asterisk 12 is below.

Configure pjsip.conf

No Format


Configure extensions.conf

the sipml5 client, for the purposes of making calls to/from Asterisk within a web browser.  You must be running a recent (as of September 2018) version of a Mozilla or Chromium based web browser.

Table of Contents

Setup Asterisk

Follow the instructions at Configuring Asterisk for WebRTC Clients before proceeding,  The rest of this tutorial assumes that your PBX is reachable at and that the client is known as webrtc_client.

Configure Asterisk Dialplan

We'll make a simple dialplan for receiving a test call from the


sipml5 client.


Code Block


exten => 


same => n,Playback(demo-congrats)
same => n,Hangup()



This instructs Asterisk to Answer a call to "200," to play a file named "demo-congrats"


Configure the firewall in front of Asterisk


(included in Asterisk's core sound file packages), and to hang up.  To make the extension active, either restart Asterisk or issue a "dialplan reload" command from the Asterisk CLI.

Browsers and WSS

When using WSS as a transport, Chrome and Firefox will not allow you, by default, to connect using WSS to a server with a self-signed certificate.  Rather, you'll have to install a publicly-signed certificate into Asterisk.  Or, you'll have to import the the self-signed certificate we made earlier into your browser's keychain, which is outside the scope of


No Format
To                         Action      From
--                         ------      ----
5060                       ALLOW IN    Anywhere
8088/tcp                   ALLOW IN    Anywhere
10000:20000/udp            ALLOW IN    Anywhere

You may wish to reconfigure your services to non-standard ports, or narrow the possible source addresses for additional security.

5060: This is the port configured in sip.conf
8088: This is the port configured in http.conf
10000:20000: This is the port range configured in rtp.conf

Configure SIPML5

Goto in your Chrome browser and use the live demo.

On the registration page use the following configuration, replacing the IP addresses with your public IP for the Asterisk server.

Image Removed

Open the "Expert mode" settings page and use the following details, still replacing the IP of course:

Image Removed

Be sure to hit save! Just leave that tab open, or close it and go back to the main tab to make a test call.

Make a test call

Restart Asterisk, or start Asterisk if you haven't already.

Click "Login" with the SIPML5 client. On the Asterisk CLI you should see:


this Wiki.  

Or, for Firefox and Chrome, you can open a separate browser tab and point it to Asterisk's HTTPs server's TLS port and WS path, e.g., and you can manually confirm the security exception.

Configure SIPML5



SIPML5 is a useful client for testing Asterisk. Many real-world users explore other options that may include rolling your own client.

Next, visit - you'll be redirected to

Once there, click the "Enjoy our live demo" link to be directed to the sipml5 client.

In the Registration box, use configuration similar to the following:

Image Added

Here, we have input the following:

  • Display Name is a free-form string
  • Private Identity is our username from our PJSIP auth object
  • Public Identity is in the format: 
    • sip : (name of our PJSIP aor object) @ (IP Address of the Asterisk system)
  • Password is our password from our PJSIP auth object
  • Realm is ""

Next, click the "Expert mode?" form button.  It will open a new browser tab.  In the Expert settings box, use a configuration similar to the following:

Image Added


Here, we have made the following changes:

  • Checked the "Disable Video" box
  • Filled in the WebSocket Server URL using the format:
    • wss : // (ip address of asterisk) : 8089 / ws
  • Checked the "Disable 3GPP Early IMS" box

Click "Save" and return to the other demo tab with the Registration box.

Next, click "Login" and you should see Connected as such:

Image Added


You should see a corresponding connection happen on the Asterisk CLI.  You can log into the Asterisk CLI by performing:

No Format
# asterisk -vvvr


Then, you can LogOut and Login and see something like:

No Format
== WebSocket connection from '










49976' for protocol 'sip' accepted using version '13'






contact '


Dial extension 1000 from your SIPML5 client and you should see CLI output:

No Format
  == Using SIP RTP CoS mark 5
    -- Executing [1000@from-internal:1] Answer("SIP/6001-00000000", "") in new stack
       > 0x28057f0 -- Probation passed - setting RTP source address to X.X.X.X:9177
    -- Executing [1000@from-internal:2] Playback("SIP/6001-00000000", "demo-congrats") in new stack
    -- <SIP/6001-00000000> Playing 'demo-congrats.gsm' (language 'en')

If you don't have VERBOSE messages going to the console, and verbosity turned up at least to 3 then you may not see these messages.


When you attempt the call, Chrome may ask you for access to your microphone or camera. Be sure to say yes!


sips:webrtc_client@;transport=ws;rtcweb-breaker=no' to AOR 'webrtc_client' with expiration of 200 seconds
== Endpoint webrtc_client is now Reachable

Make a test call

In the sipml5 Call control box input 200.  Then press the Call button.  You'll see a drop-down:

Image Added

Select "Audio" to continue.  Once you do this, Firefox will display a popup asking permission to use your microphone:

Image Added

Click "Allow."

Next, the Call control box will indicate that the call is proceeding:

Image Added

Finally, when the call is connected, you will see In Call:

Image Added

and you will hear "Congratulations, you have successfully installed and executed the Asterisk open source PBX..."

You've just made your first call via WebRTC using Asterisk!


Table of Contents