asterisk / node-ari-client

Node.js client for ARI. This library is best effort with limited support.
Other
259 stars 102 forks source link

Asterisk ARI Issue #158

Open luckyboy125 opened 1 year ago

luckyboy125 commented 1 year ago

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.

RizeKishimaro commented 11 months ago

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

AimHigh0601 commented 8 months ago

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.

dorlanpabon commented 8 months ago

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?

AimHigh0601 commented 8 months ago

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

dorlanpabon commented 8 months ago

@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");

AimHigh0601 commented 8 months ago

image Yes, I run this code

dorlanpabon commented 8 months ago

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

AimHigh0601 commented 8 months ago

It doesn't work.

dorlanpabon commented 8 months ago

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

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

dorlanpabon commented 8 months ago

Try

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

dorlanpabon commented 8 months ago

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

AimHigh0601 commented 8 months ago

image image Please check these.

dorlanpabon commented 8 months ago

uncoment line enable=yes in line 29

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

AimHigh0601 commented 8 months ago

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

AimHigh0601 commented 8 months ago

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

dorlanpabon commented 8 months ago

This warning is a recomendation, but not is an error

dorlanpabon commented 8 months ago

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

AimHigh0601 commented 8 months ago

Thank you, @dorlanpabon May I ask you more?

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

AimHigh0601 commented 8 months ago

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

AimHigh0601 commented 8 months ago

Hola @dorlanpabon Puedo preguntarte más?

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

dorlanpabon commented 8 months ago

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

AimHigh0601 commented 8 months ago

¿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

dorlanpabon commented 8 months ago

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

AimHigh0601 commented 8 months ago

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 :)