Configuring WebRTC in Asterisk (FreePBX)

Technical requirements

  • The telephony server must be accessible from the Internet, i.e. it must have a static IP.

  • Must have a working SSL/TLS certificate.

  • Asterisk version not less than 11 (?), but for convenience preferably 15 (?) or at least 13 (?).

  • When using browser-based softphone, wss (WebSocket Secure) must be configured on the Asterisk server, and the port must be open to the outside (usually 8089) (?).

    This is configured in the admin interface:

    Advanced Settings > Asterisk Builtin mini-HTTP section > HTTPS Bind Port

  • Port range for RTP (typically 10000-20000) (?).

    It is configured in the administrator interface:

    Settings → Asterisk SIP Settings → General SIP Settings Tab

Setting

This example describes how to configure WebRTC in an already running FreePBX server:

  • is available at <example>.com and has an SSL/TLS certificate;

  • FreePBX version 16, Asterisk version 15;

  • wss is configured on port 8089;

  • all other relevant ports are open.

Configuring FreePBX

If the "Change To CHAN_PjSIP Driver" button (see below, in the internal number setting) is available, you do not need to do anything in this section.

Settings ➝ Advanced Settings

Section Dialplan and Operational

SIP Channel Driver

both

Settings ➝ Asterisk SIP Settings

Tab “SIP Legacy Settings [chan_sip]”

Verify that the variables are set:

Section Advanced General Settings

Other SIP Settings

icesupport = yes

media_encryption = dtls

tlscipher = AES256-SHA

Creating and setting up an extension number (extension)

Go to the FreePBX configuration interface and log in: https://<example>.com/

Go to section Applications ➝ Extensions

Button “+ Add Extension+ Add New SIP (Legacy) [chan_sip] Extension” (other versions of FreePBX may be “Add New Chan_SIP extension”)

In the tab General:

Section Add Extension

User Extension

1001

Display Name

1001

Press the button Submit

After that, open editing of the newly created extension in the list of extensions (in the line with 5001 in the Actions column, click the edit button with a pencil icon).

Go to the tab Advanced

First change the SIP Driver to PjSIP:

Tab Advanced → Section Edit Extension

Enable WebRTC defaults

Yes

Media Encryption

DTLS-SRTP (not recommended)

Press the button Submit

Then change the SIP Driver back:

Tab Advanced → Section Edit Extension

Change SIP Driver

Change To CHAN_SIP Driver

Now to make the remaining customizations:

Tab Advanced → Section Edit Extension

Transport

All - WSS Primary

Enable AVPF

Yes

Force AVP

Yes

Enable ICE Support

Yes

Enable rtcp Mux

Yes

Enable Encryption

Yes (SRTP only)

Section DTLS

Enable DTLS

Yes (there should be)

Use Certificate

<example>.com

Press the button Submit

Press the button Apply Config

Testing that wss works

Let's use the sipML5 live demo from Doubango as an example:

https://www.doubango.org/sipml5/call.htm

Setting

First, the "Expert mode?" button.

The advanced settings page should open in the next tab

Disable Videov (checkmark)

WebSocket Server URL

wss://.com:8089/ws

Press the button Save

Back to the main tab

Display Name1001

Private Identity

1001

Public Identity

sip:1001@<example>.com

Password

Copy from FreePBX settings

Extension: 1001 ➝ General tab ➝ Edit Extension ➝ Secret

Realm

<example>.com

Button Login

The word Connected should appear at the top above the Registration heading.

Call

Now you can make the call.

Under the Call control heading, dial the desired number (*43 for an echo call or a cell phone number with 8 first).

Press the button Call ➝ Audio

There's a call that should go out.

Profit!

WebRTC support in Asterisk

Initial support for WebRTC in Asterisk starting with version 11:

PjSIP in Asterisk

FreePBX

Configuration examples

Last updated