Configuring WebRTC in Asterisk (FreePBX)
- The telephony server must be accessible from the Internet, i.e. it must have a static IP.
- Must have a working SSL/TLS certificate.
- 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
- It is configured in the administrator interface:Settings → Asterisk SIP Settings → General SIP Settings Tab
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.
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 | Text |
---|---|
SIP Channel Driver | both |
Settings ➝ Asterisk SIP Settings
Tab “SIP Legacy Settings [chan_sip]”
Verify that the variables are set:
Section Advanced General Settings | Text |
---|---|
Other SIP Settings | icesupport = yes media_encryption = dtls tlscipher = AES256-SHA |
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 | Text |
---|---|
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 | Text |
---|---|
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 | Text |
---|---|
Change SIP Driver | Change To CHAN_SIP Driver |
Now to make the remaining customizations:
Tab Advanced → Section Edit Extension | Text |
---|---|
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
Let's use the sipML5 live demo from Doubango as an example:
First, the "Expert mode?" button.
The advanced settings page should open in the next tab
Disable Video | v (checkmark) |
---|---|
WebSocket Server URL | wss://.com:8089/ws |
Press the button Save
Back to the main tab
Display Name | 1001 |
---|---|
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.
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!
Initial support for WebRTC in Asterisk starting with version 11:
- PjSIP is available by default in Asterisk 15: PJSIP-pjproject - Asterisk Project - Asterisk Project Wiki