Harnessing Asterisk: Configuring a Seamless Web Softphone Experience

Ken OsagieKen Osagie
3 min read

Introduction:

Asterisk, renowned for its flexibility and robust features as an open-source communication platform, has garnered widespread acclaim. When coupled with a web softphone, it transforms into a potent tool for facilitating Voice over IP (VoIP) communication directly through a web browser. This article delves into the step-by-step process of configuring Asterisk with a web softphone, providing a convenient and efficient means of communication.

Understanding Asterisk:

Asterisk stands as a formidable and extensible open-source platform designed for developing communication applications. Supporting various communication protocols, it proves versatile for applications such as IP PBX systems, conference servers, and VoIP gateways.

Web Softphone Overview:

A web softphone, a software-based phone operating directly from a web browser, eliminates the need for dedicated hardware or traditional phone lines. Leveraging VoIP technology, it enables voice and video calls, instant messaging, and other communication features over the Internet.

Note: While this article does not focus on building a WebRTC client, the following repositories can guide you through the process using the SIP.js library:

Setting up Asterisk:

For Non-Linux Users: If your machine does not run on Linux, you can install Asterisk on a virtual environment using the Issabel ISO available at Issabel Download. Follow the standard installation procedure for a Linux distribution.

Configuring Asterisk for WebRTC Clients:

Create Certificates:

Asterisk provides the ast_tls_cert script in the contrib/scripts source directory for generating self-signed certificates. Execute the following commands from the Asterisk source directory, replacing placeholders as needed.

sudo mkdir /etc/asterisk/keys
sudo contrib/scripts/ast_tls_cert -C pbx.example.com -O "My Organization" -b 2048 -d /etc/asterisk/keys

Configure Asterisk's Built-in HTTP Server:

Edit /etc/asterisk/http.conf:

[general]
enabled=yes
bindaddr=0.0.0.0
bindport=8088
tlsenable=yes
tlsbindaddr=0.0.0.0:8089
tlscertfile=/etc/asterisk/keys/asterisk.crt
tlsprivatekey=/etc/asterisk/keys/asterisk.key

Asterisk CLI:

*CLI> http show status

Configure PJSIP:

Edit /etc/asterisk/pjsip.conf:

[transport-wss]
type=transport
protocol=wss
bind=0.0.0.0
; All other transport parameters are ignored for wss transports.

PJSIP Endpoint, AOR, and Auth:

We now need to create the basic PJSIP objects that represent the client. In this example, we'll call the client webrtc_client but you can use any name you like, such as an extension number. Only the minimum options needed for a working configuration are shown. NOTE: It's normal for multiple objects in pjsip.conf to have the same name as long as the types differ.

Edit /etc/asterisk/pjsip.conf:

[webrtc_client]
type=aor
max_contacts=5
remove_existing=yes

[webrtc_client]
type=auth
auth_type=userpass
username=webrtc_client
password=webrtc_client ; This is a completely insecure password! Do NOT expose this 
 ; system to the Internet without utilizing a better password.

[webrtc_client]
type=endpoint
aors=webrtc_client
auth=webrtc_client
dtls_auto_generate_cert=yes
webrtc=yes
context=default
disallow=all
allow=opus,ulaw

Restart Asterisk:

Restart Asterisk to apply the changes. Ensure TCP port 8089 is allowed through your firewall.

Conclusion:

Configuring Asterisk with a web softphone presents a flexible and scalable communication solution, especially where traditional hardware phones are impractical. By following the outlined steps, you can seamlessly integrate Asterisk and web softphones to enhance communication within your organization or project. Note that specific configurations may vary, so consult the documentation of your chosen software for detailed instructions.

0
Subscribe to my newsletter

Read articles from Ken Osagie directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Ken Osagie
Ken Osagie