node-ari-client icon indicating copy to clipboard operation
node-ari-client copied to clipboard

Asterisk ARI Issue

Open luckyboy125 opened this issue 1 year ago • 24 comments

Hello, everyone. I have purchased a FreePBX app in DigitalOcean. So I could access FreePBX admin panel and I got some endpoints. Btw, I made a node server to test APIs and installed ari-client node module in it. I tried to connect server using below codes, but it doesn't work. (It even doesn't give me an error)

const client = require("ari-client");

client .connect("https://ip_addr/admin/api/api/rest", "username", "password") .then(function (ari) { console.log(ari); }) .catch(function (err) { console.log(err); });

If you have worked in this field, hope to hear from you. Thank you.

luckyboy125 avatar Nov 24 '23 19:11 luckyboy125

Have You Tried Enable the ARI in Config files? If it's not You Should enable it,

Your code seems fine but you have to connect to ari when the server is initialized, try using Node-lifecycle

the will ensure that when your server is started it will connect to the ARI endpoint

and remember the ari restapi default endpoint is http://ip:8088/ari

RizeKishimaro avatar Dec 21 '23 04:12 RizeKishimaro

Hi, @RizeKishimaro

I installed Asterisk server in my Ubuntu PC. I tried to connect Zoiper 5 soft phone to Asterisk server and it worked well. I connected using local IP address. (192.168..*) I tried to connect to Asterisk server in Node.js server. Here is my code: `const client = require("ari-client");

const ENDPOINT = "PJSIP/100";

client.connect( "http://{my global IP address}:8088/ari", "6001", // username "mypassword", // password function (err, ari) { console.log("Connecting to Asterisk Package!"); if (err) { console.log("Asterisk Error : ", err); return; } }) `

When I tried with local IP address, it's failed w/ errno -111. (HostIsNotReachable) But when I run that code, I get nothing. Even I couldn't see any logs in terminal. If it's succeeded, I have to see any log among them. I am not sure what the problem is in the connection. image

Hope to hear from you soon. Thank you.

AimHigh0601 avatar Mar 05 '24 12:03 AimHigh0601

Good morning @AimHigh0601 , you asterisk runing in your machine?, the config ari.conf have enabled =yes?, the config ari.conf have comment the rule allowed_origins? You has send capture ari.conf?

dorlanpabon avatar Mar 05 '24 13:03 dorlanpabon

Thank you, @dorlanpabon image I just changed asterisk user info, and also tried with it. But it didn't work, same error.

AimHigh0601 avatar Mar 05 '24 13:03 AimHigh0601

@AimHigh0601 , you use the user aritest and password in ariclient? restart diaplan or restart asterisk with now config? Example: client = await ariClient.connect("http://localhost:8088", "aritest", "testme");

dorlanpabon avatar Mar 05 '24 13:03 dorlanpabon

image Yes, I run this code

AimHigh0601 avatar Mar 05 '24 13:03 AimHigh0601

delete ari of URL , "http://localhost:8088/"

dorlanpabon avatar Mar 05 '24 14:03 dorlanpabon

It doesn't work.

AimHigh0601 avatar Mar 05 '24 14:03 AimHigh0601

in my case work, with http://localhost:8080

Try delete / of URL; you has meet and review?

dorlanpabon avatar Mar 05 '24 14:03 dorlanpabon

Try

curl -u aritest:testme http://localhost:8088/ari/asterisk/info

dorlanpabon avatar Mar 05 '24 14:03 dorlanpabon

view http.conf and propertie "bindport" and "bindaddr" and "enabled"

dorlanpabon avatar Mar 05 '24 14:03 dorlanpabon

image image Please check these.

AimHigh0601 avatar Mar 05 '24 16:03 AimHigh0601

uncoment line enable=yes in line 29

A Question, the virtual machine have communication with your pc?

dorlanpabon avatar Mar 05 '24 21:03 dorlanpabon

I run the node server in that virtual machine. I will try again after I activate line 29.

AimHigh0601 avatar Mar 05 '24 21:03 AimHigh0601

Wow, it worked. But I got this error (warning). image

AimHigh0601 avatar Mar 05 '24 21:03 AimHigh0601

This warning is a recomendation, but not is an error

dorlanpabon avatar Mar 05 '24 22:03 dorlanpabon

Note: Not speak english, i am speak spanish, i am practice jejejej

dorlanpabon avatar Mar 05 '24 22:03 dorlanpabon

Thank you, @dorlanpabon May I ask you more?

Can I make an outbound call to global phone number using ARI?

AimHigh0601 avatar Mar 05 '24 22:03 AimHigh0601

If anyone has implemented an outbound calling system using ARI, please let me know how you did it. Thank you.

AimHigh0601 avatar Mar 07 '24 06:03 AimHigh0601

Hola @dorlanpabon Puedo preguntarte más?

Puedo hacer una llamada saliente a un número de teléfono global usando ARI?

AimHigh0601 avatar Mar 07 '24 11:03 AimHigh0601

Good morning @AimHigh0601 , for call outbound global, you must have a trunk provider. example: https://www.didww.com/coverage-and-prices/sip-trunking-pricing

If you have a sip trunk with user and password, you was do edit config asterisk to connect the sip trunk for call outbound

ARI in the end is a API of asterisk, to manage actions, example, play audio, route call, make call, but asterisk has connect to sip to was do call outbound global

dorlanpabon avatar Mar 07 '24 12:03 dorlanpabon

¿Quieres decir que tienes experiencia en el servicio DIDWW? Si es así, tengo algunas preguntas. 1. ¿El servicio DIDWW proporciona Rest API para iniciar, transferir y finalizar una llamada y rastrear una llamada (obtener eventos de clave)? 2. ¿Qué softphone proporciona DIDWW? De lo contrario, ¿qué podemos usar para ello? 3. ¿Su sugerencia es que podemos obtener un troncal SIP de DIDWW y administrar una llamada a través del servidor Asterisk? En este caso, ¿funciona correctamente para las dos preguntas anteriores? Gracias. @dorlanpabon

AimHigh0601 avatar Mar 07 '24 16:03 AimHigh0601

@AimHigh0601 , you can buy sip trunk, after connect asterisk to the sip trunk, then management the call with asterisk using ARI

dorlanpabon avatar Mar 07 '24 18:03 dorlanpabon

Entiendo. Gracias @dorlanpabon Sólo quiero comprar números turcos y crear un sistema VOIP para números TR. Hablé con el equipo de soporte de DIDWW, pero no proporcionan números TR. ¿Utilizó sólo DIDWW para el sistema VOIP? Hay canales, puentes y aplicaciones en Asterisk. ¿Podemos hacer una llamada saliente usando estos (Asterisk)? ¿Necesitamos simplemente servicios de terceros para una llamada global? Si conoces más servicios, por favor házmelo saber :)

AimHigh0601 avatar Mar 07 '24 19:03 AimHigh0601