AMP AMP

How to enable Asterisk ARI and Connect with WebSocket on Debian 12

To Enable Asterisk ARI With Connect Websocket On Debian 12

Introduction:

ARI is an asynchronous API that allows developers to build communications applications by exposing the raw primitive objects in Asterisk - channels, bridges, endpoints, media, etc. - through an intuitive REST interface. The state of the objects the user controls is conveyed via JSON events over a WebSocket.

Procedure:

Step 1: Check the OS version by using following command.

root@linuxhelp:~# cat /etc/os-release
PRETTY_NAME="Debian GNU/Linux 12 (bookworm)"
NAME="Debian GNU/Linux"
VERSION_ID="12"
VERSION="12 (bookworm)"
VERSION_CODENAME=bookworm
ID=debian
HOME_URL="https://www.debian.org/"
SUPPORT_URL="https://www.debian.org/support"
BUG_REPORT_URL=https://bugs.debian.org/

Step 2: Check the Asterisk version by using following command.

root@linuxhelp:~# asterisk -V
Asterisk 20.4.0

Step 3: Go to the following location by using following command.

root@linuxhelp:~# cd /etc/asterisk

Step 4: Open ari.conf file and Make configuration of ari by using following command.

root@linuxhelp:/etc/asterisk# vim ari.conf
[general]
enabled = yes      
pretty = yes        
allowed_origins = * 
[linuxhelp]
type = user 
read_only = no 
password = 123456

Step 5: Open http.conf file and make the web configuration for ARI by using following command.

root@linuxhelp:/etc/asterisk# vim http.conf 
[general]
servername=Asterisk
enabled=yes
bindaddr=0.0.0.0
bindport=8088
prefix=asterisk

Step 6: Login to the Asterisk by using following command.

root@linuxhelp:~# asterisk -rvvvvvvvvvvvvvvvvvvvvvvvvvvv
Asterisk 20.4.0, Copyright (C) 1999 - 2022, Sangoma Technologies Corporation and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 20.4.0 currently running on linuxhelp (pid = 1363)
linuxhelp*CLI>

Step 7: Reload the modules by using following command.

linuxhelp*CLI> core reload
    -- Reloading module 'extconfig' (Configuration)
    -- Reloading module 'logger' (Logger)
 Asterisk Queue Logger restarted
    -- Reloading module 'cdr' (CDR Engine)
[Jan 27 03:41:42] NOTICE[46283]: cdr.c:4568 cdr_toggle_runtime_options: CDR simple logging enabled.
    -- Reloading module 'cel' (CEL Engine)
    -- Reloading module 'features' (Call Features)
    -- Reloading module 'http' (Built-in HTTP Server)
 Bound HTTP server 'http server' to address 0.0.0.0:8088
    -- Reloading module 'indications' (Indication Tone Handling)
    -- Reloading module 'res_pjproject.so' (PJPROJECT Log and Utility Support)
    -- Reloading module 'res_pjsip.so' (Basic SIP resource)
[Jan 27 03:41:42] NOTICE[45739]: sorcery.c:1348 sorcery_object_load: Type 'system' is not reloadable, maintaining previous values
    -- Reloading module 'res_pjsip_authenticator_digest.so' (PJSIP authentication resource)
    -- Reloading module 'res_pjsip_endpoint_identifier_ip.so' (PJSIP IP endpoint identifier)
    -- Reloading module 'res_musiconhold.so' (Music On Hold Resource)
    -- Time to delete the old dialplan: 0.000009 sec
    -- Total time merge_contexts_delete: 0.000027 sec
    -- pbx_config successfully loaded 1 contexts (enable debug for details).
    -- Reloading module 'app_queue.so' (True Call Queueing)
[Jan 27 03:41:42] NOTICE[46283]: app_queue.c:9528 reload_queue_rules: queuerules.conf has not changed since it was last loaded. Not taking any action.
    -- Reloading module 'cel_custom.so' (Customizable Comma Separated Values CEL Backend)
    -- Added CEL CSV mapping for '/var/log/asterisk/cel-custom/Minecel.csv'.
 Added CEL CSV mapping for 1 files.

Step 8: Check the ARI status by using following command.

linuxhelp*CLI> module load res_stasis.so
Loaded res_stasis.so
  == Message handler 'ari' registered.
 Loaded res_stasis.so => (Stasis application support)
linuxhelp*CLI> module load res_ari
Loaded res_ari
 Loaded res_ari.so => (Asterisk RESTful Interface)
linuxhelp*CLI> ari show status
ARI Status:
Enabled: Yes
Output format: pretty
Auth realm: Asterisk REST Interface
Allowed Origins: *
User count: 1

Step 9: Check the http status by using following command.

linuxhelp*CLI> http show status
HTTP Server Status:
Prefix: /asterisk
Server: Asterisk
Server Enabled and Bound to 0.0.0.0:8088

Enabled URI's:
/asterisk/httpstatus => Asterisk HTTP General Status
/asterisk/static/... => Asterisk HTTP Static Delivery
/asterisk/ari/... => Asterisk RESTful API
/asterisk/ws => Asterisk HTTP WebSocket

Enabled Redirects:
  None.

Step 10: Goto the browser and search the Asterisk server IP address with the path as shown below image

Conclusion:

We have reached the end of this article. In this guide, we have walked you through the steps required to enable Asterisk ARI with connect WebSocket on Debian 12. Your feedback is much welcome.

FAQ
Q
Where can I get help with ARI?
A
Asterisk documentation and tutorials
Asterisk Community Forum
ARI library documentation
Q
How secure is ARI?
A
ARI uses HTTPS and authentication for secure communication.
Q
Do I need to modify the Asterisk dialplan for ARI?
A
Yes, a basic dialplan configuration is required to trigger ARI applications.
Q
What programming languages can I use with ARI?
A
Any language is capable of HTTP or WebSockets, such as Python, Java, Javascript, PHP, etc.
Q
What features does ARI offer?
A
Control call routing and bridging
Play audio and record calls
Collect DTMF
Manage conferences
Access real-time call and channel information