How to enable ARI and Connect with WebSocket on Asterisk on Oracle Linux 9.3
To Enable ARI And Connect With WebSocket On Asterisk On Oracle Linux 9.3
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 Steps:
Step 1: Check the OS version by using the below command
[root@linuxhelp ~]# cat /etc/os-release
NAME="Oracle Linux Server"
VERSION="9.3"
ID="ol"
ID_LIKE="fedora"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="9.3"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Oracle Linux Server 9.3"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:9:3:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://github.com/oracle/oracle-linux"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 9"
ORACLE_BUGZILLA_PRODUCT_VERSION=9.3
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=9.3
Step 2: Now check the status of the Asterisk service by using the below command
[root@linuxhelp ~]# systemctl status asterisk.service
● asterisk.service - LSB: Asterisk PBX
Loaded: loaded (/etc/rc.d/init.d/asterisk; generated)
Active: active (running) since Mon 2024-02-19 04:02:05 IST; 2 months 23 days ago
Docs: man:systemd-sysv-generator(8)
Process: 1001 ExecStart=/etc/rc.d/init.d/asterisk start (code=exited, status=0/SUCCESS)
Main PID: 1062
Tasks: 37 (limit: 21739)
Memory: 63.3M
CPU: 6.710s
CGroup: /system.slice/asterisk.service
├─1056 /bin/sh /usr/sbin/safe_asterisk
└─5831 /usr/sbin/asterisk -f -vvvg -c
Feb 19 04:02:05 linuxhelp systemd[1]: Starting LSB: Asterisk PBX...
Feb 19 04:02:05 linuxhelp asterisk[1001]: Starting asterisk:
Feb 19 04:02:05 linuxhelp systemd[1]: asterisk.service: Can't open PID file /run/asterisk/asterisk.pid (yet?) after start: Operation not permitted
Feb 19 04:02:05 linuxhelp systemd[1]: asterisk.service: Supervising process 1062 which is not our child. We'll most likely not notice when it exits.
Feb 19 04:02:05 linuxhelp systemd[1]: Started LSB: Asterisk PBX.
Step 3: For enabling ARI, First move to the Asterisk directory by using the below command
[root@linuxhelp ~]# cd /etc/asterisk/
[root@linuxhelp asterisk]#
Step 4: Edit ari.conf file by using the below command
[root@linuxhelp asterisk]# vim ari.conf
Check for the following line
enabled=yes
Add the following lines in the ari.conf file
[asterisk]
type=user
read_only=no
password=Linuxc#4
password_format=plain
Step 5: Now ARI has been enabled, need to configure http on asterisk, edit http.conf file in the asterisk directory by using the below command
[root@linuxhelp asterisk]# vim http.conf
Check the following lines in the http.conf file and enter the values like below lines
[general]
enabled=yes
bindaddr=0.0.0.0
bindport=8088
Step 6: Now Login to the Asterisk CLI Mode by using the below command
[root@linuxhelp asterisk]# asterisk -rvvvvvvvvvvvvv
Asterisk 20.5.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.5.0 currently running on linuxhelp (pid = 6223)
linuxhelp*CLI>
Step 7: Check the ARI status by using the below 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: compact
Auth realm: Asterisk REST Interface
Allowed Origins:
User count: 1
Step 8: Check the http status by using the below command
linuxhelp*CLI> http show status
HTTP Server Status:
Prefix:
Server: Asterisk
Server Disabled
Enabled URI's:
/httpstatus => Asterisk HTTP General Status
/ari/... => Asterisk RESTful API
/ws => Asterisk HTTP WebSocket
Enabled Redirects:
None.
Step 9: Go to the browser and search with the following link http://enter-your-ip:8088/ari
Here I’m using my IP address http://192.168.6.140:8088/ari
Step10: After enter the above link enter your Username and Password
Conclusion:
We have reached the end of this article. In this guide, we have walked you through the steps required to enable ARI and connect with Web Socket on Asterisk on Oracle Linux 9.3. Your feedback is much welcome.
Comments ( 0 )
No comments available