entone

entone

ExARI

https://github.com/CityBaseInc/ex_ari

An Elixir library for interfacing with Asterisk using the ARI protocol.

Be sure to check out the example application GitHub - CityBaseInc/ex_ari_example: Example application showing real world usage of the ex_ari library to control an Asterisks server · GitHub

The ARI protocol is a robust interface for controlling Asterisk and reacting to Asterisk events. It has been thoroughly tested with Asterisk versions 15 and 16.

ARI stands for Asterisk REST Interface. Through the REST interface it is possible to control just about every aspect of an Asterisk server. ARI also provides a Websocket interface for consuming events from the Asterisk Server. This library has full support for both the REST and Websocket protocols.

If you’re not to familiar with Asterisk, there’s an example repo that will get you up and running with a custom Asterisk IVR in a few minutes, GitHub - CityBaseInc/ex_ari_example: Example application showing real world usage of the ex_ari library to control an Asterisks server · GitHub .

The documentation is pretty thorough, but it definitely helps to understand Asterisk and ARI.

Check the docs here, ARI — ARI v0.1.2

and on hex.pm ex_ari | Hex

Brought to you by CityBase

Showing Posts 1 to 10

trarbr

trarbr

I haven’t even looked at the code yet but I know I am going to love this :heart:

trarbr

trarbr

So I wanted to try the ex_ari_example out last night, but I had some trouble with the Asterisk part. I haven’t played with Asterisk before so I’m not really sure what’s going wrong.

  1. The docker run ... command uses --net host, which doesn’t work on Mac unfortunately. So I ran it like this instead: docker run -p 8088:8088 -p 8089:8089 -p 5062:5062/tcp -p 5062:5062/udp -p 10000-10099:10000-10099/udp --name asterisk -v $PWD/asterisk_local_config/pjsip.conf:/etc/asterisk/pjsip.conf ex-ari-asterisk (I googled around a bit and guessed at the ports). After this, I could start the project with iex -S mix and it connected!
  2. However, I was unable to connect to Asterisk with Zoiper. On the accounts page it says Request Timeout (code: 408) and there is nothing in the Asterisk logs.
  3. I then tried running the Asterisk container inside an Ubuntu virtual machine, using --net host, and running it on a bridged network (VM had IP 192.168.33.10). I changed all the references to 127.0.0.1 to 192.168.33.10 in dev.env, so the Elixir project works fine. But Zoiper gives me a new error now. Instead of Request Timeout (code: 408) error, I now get Unauthorized (code: 401) and I see this in the Asterisk logs:
[Feb 14 07:29:30] NOTICE[37]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'REGISTER' from '<sip:ex_ari@192.168.33.10>' failed for '192.168.33.1:5063' (callid: _R51m7KNwSEepDSdZ6NrSA..) - No matching endpoint found
[Feb 14 07:29:30] NOTICE[37]: res_pjsip/pjsip_distributor.c:676 log_failed_request: Request 'REGISTER' from '<sip:ex_ari@192.168.33.10>' failed for '192.168.33.1:5063' (callid: _R51m7KNwSEepDSdZ6NrSA..) - Failed to authenticate
<--- Transmitting SIP response (505 bytes) to UDP:192.168.33.1:5063 --->
SIP/2.0 401 Unauthorized
Via: SIP/2.0/UDP 192.168.33.1:5063;rport=5063;received=192.168.33.1;branch=z9hG4bK-524287-1---339444ffe79eb675
Call-ID: _R51m7KNwSEepDSdZ6NrSA..
From: <sip:ex_ari@192.168.33.10>;tag=5292835a
To: <sip:ex_ari@192.168.33.10>;tag=z9hG4bK-524287-1---339444ffe79eb675
CSeq: 2 REGISTER
WWW-Authenticate: Digest realm="ex_ari",nonce="1581665370/39d4d6299126e965bb54cf6033f8eca3",opaque="389d044662fe0ad8",algorithm=md5,qop="auth"
Server: Asterisk PBX 16.3.0
Content-Length:  0

I wonder if I am using the wrong username/password?

lawik

lawik

Nerves Core Team

Super curious about this stuff. I don’t have the time anytime soon to dive into Asterisk but damn if I don’t want to :slight_smile:

Considering the Erlang/OTP telecommunications heritage, are there previous solutions to work with Asterisk around, do you know?

Cool that you are doing and releasing this!

entone

entone OP

I run Linux so haven’t had the Mac issues. It looks like you got really really close! I should probably be explicit about the demo only working on Linux as of now.

I’ll dig in a bit more in a few hours. Asterisk is NOT simple to setup. If we get it working would be great if you could write-up some notes for Mac dev.

entone

entone OP

It looks like your port is incorrect in your Zoiper settings.

Under Settings -> Advanced -> Network

All the way at the bottom.

Make sure your SIP Options port is set to 5062 and the Open random port above 32000 is unchecked

You may need to update the AOR_IPS in dev.env to be 192.168.33.1:5062 as well.

But give it a try with just the port update in Zoiper first.

trarbr

trarbr

No worries. Thank you so much for putting this out. I’ll dig into it, and see if I can get it working. And if I do I’ll be happy to add contribute it back :slight_smile:

odix67

odix67

Just want to ask, if there is any work done this library, stands still for a few years, latest version from GitHub isn’t compilable (just little code inconsistencies) ?

entone

entone OP

I haven’t been working on it lately, and I see that Citybase archived it. I was able to get them to transfer ownership to my org before I left. You can find the “active” repo here, GitHub - entropealabs/ex_ari: An Elixir Library for interfacing with Asterisk the Open Source Communications Software using ARI · GitHub

PRs are welcome if you’d like to update it.

odix67

odix67

thx, that’s great! I’ve already forked it and found an issue related to the stasis state implementation, the :type attribute is mentioned in the json encode, but not available in the defstruct (part of stasis.ex):

 defmodule State do
    @moduledoc false
    @type t :: %__MODULE__{}

    @derive {Jason.Encoder, only: [:connected, :url, :status, :type]}
    defstruct [
      :connected,
      :url,
      :status,
      :channel_supervisor,
      reconnection_attempts: 0,
      app: %{}
    ]
  end

without going deep into ARI, do you have a quick solution for this issue ?

Where Next? Top

Trending in Announcing Top

wojtekmach
Hey everyone! Req is an HTTP client for Elixir that I’ve been working on for quite some time. There is already a lot of HTTP clients out...
New
handnot2
Samly can be used to enable SAML 2.0 Single Sign On in a Plug/Phoenix application. This library uses Erlang esaml to provide plug enabl...
New
woylie
Flop is an Elixir library that applies filtering, ordering and pagination parameters to your Ecto queries. offset-based pagination with...
New
MRdotB
I needed to reuse React components from my Chrome extension in my Phoenix/LiveView backend. I noticed that for Svelte/Vue, there are live...
New
garrison
Hobbes is a low-level distributed database for the Elixir programming language. Hobbes provides a simple, safe, and scalable storage lay...
New
marciok
Hi there! We created Gust: A task orchestrator inspired by Airflow. For those who have never heard about Aiflow, it’s a Python-based wor...
New
fuelen
Hi all! I want to present a small library which provides a mix task for generating an Entity-Relationship Diagram for Ecto schemas. You...
New

Other Trending Topics Top

mudasobwa
I am happy to introduce the very α version of the new programming language compiled to BEAM. Welcome Cure. It has literally three kille...
New
AstonJ
This showed up on my feed.. anyone heard of it? Just hype? Ox Alpha is a reasoning model designed for coding, sustained ag...
New
sergio
It’s not that it’s vocabulary is too advanced. It’s something worse. I get lost trying to follow even a paragraph written by Claude. It’...
New
sorenone
Today we’re releasing Oban for Python. Not an Oban client in Python. Not a pythonx wrapper embedded in Elixir. Nope, it’s a fully operati...
New
akoutmos
@hugobarauna, Dr. Dimitrios Koutmos (my brother) and I (Alex Koutmos) have been hard at work on writing a book on how you can use Elixir ...
New
pferriby
Introductory paragraph I’ll be looking for a keen junior or someone that has a couple of years experience in the real world (so you’ve be...
New

We're in Beta

About us Mission Statement

Options

Thread Display Mode




Thread Preview

Skip Thread Previews