Skip to end of metadata
Go to start of metadata


This page is out of date and need to be updated.

For now, check out the WebRTC tutorial using SIPML5


If you would like to test Asterisk with WebRTC you can now use the latest shipping Chrome. Audio should work great, but Asterisk 11 does not support the VP8 video codec used by Chrome at the time of this writing.

Passthrough support for the video codec VP8 (and Opus for audio) was added in Asterisk 12.


WebRTC/rtcweb is an effort to bring a defined API to JavaScript developers that allows them to venture into the world of real time communications. This may be a click-to-call system or a "softphone" with both delivered as a webpage. No plug-ins are required and as this is a defined specification it can be used across different browsers where supported.

Asterisk has had support for WebRTC since version 11. A res_http_websocket module has been created which allows the JavaScript developers to interact and communicate with Asterisk. Support for WebSocket as a transport has been added to chan_sip to allow SIP to be used as the signaling protocol. ICE, STUN, and TURN support has been added to res_rtp_asterisk to allow clients behind NAT to better communicate with Asterisk. SRTP support was added in a previous version but it is also a requirement of WebRTC.

Browser Support

The latest information about browser support is available at


Secure media is a requirement of WebRTC and as a result SRTP must be available. In order for Asterisk to build SRTP support the libsrtp library and development headers must be available. This can be installed using the distribution's package management system or from source. Failure to do this will result in the media offers being rejected.


Asterisk 11 comes with an embedded pjproject. When building Asterisk 11, to get ICE support you'll need the UUID development library (uuid-dev for Debian, libuuid-devel for CentOS) library. If you don't have ICE support, then you'll likely run into audio issues in several scenarios, specifically when attempting to traverse NAT, as WebRTC uses ICE,STUN,TURN to do this.

Starting with Asterisk 12 you need to have pjproject libraries installed, otherwise you most likely won't have audio in your WebRTC calls and no warning whatsoever!

See here for instructions on getting it installed: PJSIP-pjproject

Additionally on CentOS you may need to do "export LD_LIBRARY_PATH=/usr/lib". The alternative is passing  the correct flags (usually --with-libdir) to all dependencies to install the libraries in /usr/lib64 instead of /usr/lib. You could possibily also play with the /etc/ configuration to achieve the same effect. 

Configuring res_http_websocket

The built-in Asterisk HTTP server is used to provide the WebSocket support. This can be enabled using the following in the general section of the http.conf configuration file.

If you would like to change the port from the default value of 8088 this can also be done in the general section.

The res_http_websocket must also be built and loaded by Asterisk. For most individuals this is done by default.


Ensure that is selected in menuselect prior to building Asterisk. Also ensure that is loaded prior to if you are not using autoload in modules.conf

The secure calling tutorial viewable at can be used as a basis to configure the built-in HTTP server with HTTPS (and secure WebSocket) support.

Configuring chan_sip

All configuration occurs in sip.conf, or a configuration file included by it.

To allow a peer, user, or friend access using the WebSocket transport it must be added to their transport options like the following.

To restrict access to clients using only an HTTPS connection allow the 'wss' transport only.

The WebRTC standard has selected AVPF as the audio video profile to use for media streams. This is not the default profile in use by chan_sip. As a result the following must be added to the peer, user, or friend.

This will cause AVPF and SAVPF to be used and the media streams to be accepted.


Asterisk 11.0.0-beta1 has an issue in it where registering over WebSocket may not work properly. The work around is to use a newer version of Asterisk that has been released, or check out the Asterisk 11 branch from SVN. You can also set

on the peer, user, or friend to work around the issue.

The issue report for this problem is viewable at

As media encryption is a requirement of rtcweb the following must be added to the peer, user, or friend to enable it.

Using WebSocket

The res_http_websocket module provides WebSocket at the /ws sub-directory only. This is an implementation specific detail. Some JavaScript libraries may need to be changed slightly to explicitly use the sub-directory. Symptoms of using the incorrect URL are a 404 Not Found response from the Asterisk HTTP server.

JavaScript Libraries

1. JsSIP - Provides a WebRTC compatible JavaScript SIP library, demo is available here for download.
2. sipml5 - Provides a WebRTC compatible JavaScript SIP library.


All SIP responses are sent from Asterisk to the client.

HTTP Response: 404 Not Found

The JavaScript library is using an incorrect URL for WebSocket access. The URL must use the /ws sub-directory.

SIP Response: 400 Bad Request received over SIP when registering using WebSocket

The version of chan_sip in use has a bug when registering. Update to a newer version.

SIP Response: 488 Not acceptable here received over SIP when placing a call to Asterisk

You have not enabled AVPF support in the peer, user, or friend entry using "avpf=yes" or have not allowed a codec that is supported by the caller.

  • No labels


  1. Can I connect to Asterisk manager over websocket without any crutches ?

    I would like listen asterisk events in browser using javascript.

    Can I use code like



    1. AMI is not supported over WebSockets.

  2. Why would http://asteriskserver:8088/ws report an

    Upgrade Required



    1. The WebSocket URL requires the client to upgrade to a WebSocket connection; it won't handle plain HTTP GET's.

      If you want to see the WebSocket in action, you can use something like wscat.

      $ wscat -s echo --connect http://localhost:8088/ws
      connected (press CTRL+C to quit)
      > hello
      < hello



  3. Connecting WebRTC via WSS is not working, asterisk will not register peers over WSS, though WS works as expected.


  4. SIP.js - another WebRTC compatible JavaScript Library


    1. Hi John,

      Are you able to use SIP.js with Asterisk 13, with WebSocket secure (wss) for WebRTC?



  5. Has anyone tried video with webrtc and pjsip . In my case voice works well but video does not work even when i allow vp8 codec in pjsip.conf 

    1. Comments are purged every so often to clean up the pages. If you want to contribute to the wiki you should submit the article in a comment and we'll format it and add it to a new page , or replace the relevant old page with it. Thanks!

  6. does Asterisk provide WebRTC support other than through websockets?

    1. WebRTC is only supported using SIP as a signaling protocol, thus any transport (such as UDP or TCP) that chan_sip or chan_pjsip supports can be used.