Skip to end of metadata
Go to start of metadata

Asterisk 11 Tutorial Overview

The idea for this tutorial is to demonstrate very basic WebRTC support and functionality in Asterisk 11. We will configure Asterisk to support a remote WebRTC client, and then make calls from said client (SIPML5) to Asterisk. ICE and STUN will be used for NAT traversal, and SIP will use a WebSocket transport.


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 WebRTC. See: Secure Calling Tutorial


Support for optional RTCP-MUX is being disabled in later browsers. As a result it is recommended that you use the latest version of Asterisk (at least 13.15.0 or 14.4.0) and set the 'rtcp_mux' option to yes in either the endpoint entry in sip.conf or pjsip.conf.

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.

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

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

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:

./configure && make menuselect

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

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


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


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

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



Configure extensions.conf

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

exten => 1000,1,Answer()
same => n,Playback(demo-congrats)
same => n,Hangup()

If you haven't written dialplan before; this is just instructing Asterisk to answer the call and playback the sound file "demo-congrats".

Configure the firewall in front of Asterisk

Firewall configuration is outside the scope of the tutorial, however here is the output from my Uncomplicated FireWall service to show you what you may need to open:

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


SIPML5 is a useful client for testing Asterisk but for real world use you will want to explore the different options and potentially make your own client.


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.

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

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.


To use WSS as a transport, rather than WS, the WebSocket Server URL on the Expert Settings page should use the "wss" prefix and you should have configured Asterisk's HTTP daemon for tls operations - disabled by default, and when enabled defaults to port 8089.


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:

  == WebSocket connection from 'X.X.X.X:46723' for protocol 'sip' accepted using version '13'
    -- Registered SIP '6001' at X.X.X.X:46723
       > Saved useragent "IM-client/OMA1.0 sipML5-v1.2014.01.27" for peer 6001

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

  == 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!

You should hear audio coming from your speakers or headphone! Congrats on making your first call via WebRTC using Asterisk!


If you attempt to use WSS instead of WS as your transport, note that Chrome and Firefox will not allow you, by default, to connect, using WSS, to a server with a self-signed or otherwise invalid certificate. Rather, you'll have to install a signed certificate into Asterisk or import the server's self-signed/invalid certificate into your browser's keychain, which is outside of the scope of this Wiki. As a workaround with Firefox only, for testing or development, you can open a separate browser tab and point it to Asterisk's HTTP server's TLS port, e.g. https://[your asterisk server]:8089/ws, and confirm the security exception.



  • No labels


  1. Sounds like a question for the Elastix community:

  2. I'm install and config asterisk, webrtc in vmware. I'm login webrtc client with chrome and call to IVR. Asterisk always send rtp to external ip.

    I do not hear sound from the browse. I have to establish a connection to stun server or not?

    P/S: asterisk and client on LAN
    1. There isn't nearly enough information here about your environment and configuration to provide advice.

      If everything is on a LAN then you probably don't require a STUN server.

      This isn't the right forum to troubleshoot. You can discuss the topic in the IRC chatroom, on the mailing lists or in the forums.



  3. I just recently tested SIPML5. It has some annoying issues like unable to reconnect automatically after disconnect which is a common case on mobile networks. Sip.js and webphone seems to be more stable.

    Some other useful tutorials to setup web sip client for Asterisk:

    Also make sure to setup ICE (STUN and TURN) properly because that is very crucial for a correct WebRTC implementation (With TCP/TLS TURN you can handle the common case when UDP is blocked like in corporate networks)