ARI on freePBX (Asterisk REST Interface)

freepbx
asterisk
v7

(Alessandro) #1

NethServer Version: 7.5.1804
Module: freepbx

Hi,
i’m trying to enable and use ARI on freePBX in NethServer.
My goal is to get a web page that can display the asterisk info and make calls.
I’ve installed Asterisk REST Interface Users module and i’ve enabled, in “Settings -> Advanced Settings” the “Asterisk Builtin mini-HTTP server” and “Asterisk REST Interface”.
In “Asterisk Rest Interface Users” i’ve created a user whit write permission.
The problem is that i receive always a 404 error.

In CLI i’ve this output:
cdc*CLI> ari show status
ARI Status:
Enabled: Yes
Output format: pretty
Auth realm: Asterisk REST Interface
Allowed Origins: *
User count: 2

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

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

Enabled Redirects:
_ None._

If i try to connect from browser to:
http://ipaddress:8088/ari/asterisk/info

after entered username and password i obtain the following response:
{
“message” : “Resource not found”
}

and the following log in console:
[2018-06-27 15:28:20] DEBUG[22381]: http.c:1954 httpd_helper_thread: HTTP opening session. Top level
[2018-06-27 15:28:20] DEBUG[22381]: http.c:1430 handle_uri: HTTP Request URI is /ari/asterisk/info
[2018-06-27 15:28:20] DEBUG[22381]: http.c:1485 handle_uri: match request [ari/asterisk/info] with handler [httpstatus] len 10
[2018-06-27 15:28:20] DEBUG[22381]: http.c:1485 handle_uri: match request [ari/asterisk/info] with handler [static] len 6
[2018-06-27 15:28:20] DEBUG[22381]: http.c:1485 handle_uri: match request [ari/asterisk/info] with handler [ari] len 3
[2018-06-27 15:28:20] DEBUG[22381]: http.c:1501 handle_uri: Match made with [ari]
[2018-06-27 15:28:20] DEBUG[22381]: http.c:565 ast_http_send: HTTP keeping session open. status_code:404

The same thing in i try in console:
curl -v -u username:password -X GET “http://ipaddress:8088/ari/asterisk/info

i get:
* About to connect() to servername.xyz port 8088 (#0)
* Trying ipaddress…
* Connected to servername.xyz (ipaddress) port 8088 (#0)
* Server auth using Basic with user ‘username’
> GET /ari/asterisk/info HTTP/1.1
> Authorization: Basic YXJpcmVwbHl1c2VyOnJlcGx5
> User-Agent: curl/7.29.0
> Host: servername.xyz:8088
> Accept: /
>
< HTTP/1.1 404 Not Found
< Server: Asterisk/13.17.2
< Date: Wed, 27 Jun 2018 13:34:51 GMT
< Cache-Control: no-cache, no-store
< Content-type: application/json
< Content-Length: 37
<
{
“message”: “Resource not found”
* Connection #0 to host servername.xyz left intact

There are someone that have tryied something similar?


(Stefano Fancello) #2

I remember that you have to call your application from the dialplan using Stasis() function, and that’s the reason why we tried to use ARI but we went back to AMI (for an enterprise application) https://wiki.asterisk.org/wiki/display/AST/Getting+Started+with+ARI# <- look at the extension.conf example

Also, take a look at this
https://issues.asterisk.org/jira/browse/ASTERISK-25463
is still marked as unresolved :frowning:

Keep us posted about that, I’m very interested!

@alep @mrchiao


(Alessandro) #3

Damn… it doesn’t sounds good.
I think that i switch to AMI because i need a simple web page that show presence and send/receive calls (it’s only dimostrative).

Did you realize something like that for your enterprise application with AMI?


(Alessandro) #4

I do a little check…

cdc*CLI> module show like ari
Module                         Description                              Use Count  Status      Support Level
res_ari.so                     Asterisk RESTful Interface               0          Running              core
res_ari_applications.so        RESTful API module - Stasis application  0          Not Running          core
res_ari_asterisk.so            RESTful API module - Asterisk resources  0          Not Running          core
res_ari_bridges.so             RESTful API module - Bridge resources    0          Not Running          core
res_ari_channels.so            RESTful API module - Channel resources   0          Not Running          core
res_ari_device_states.so       RESTful API module - Device state resour 0          Not Running          core
res_ari_endpoints.so           RESTful API module - Endpoint resources  0          Not Running          core
res_ari_events.so              RESTful API module - WebSocket resource  0          Not Running          core
res_ari_model.so               ARI Model validators                     0          Running              core
res_ari_playbacks.so           RESTful API module - Playback control re 0          Not Running          core
res_ari_recordings.so          RESTful API module - Recording resources 0          Not Running          core
res_ari_sounds.so              RESTful API module - Sound resources     0          Not Running          core
12 modules loaded

then i load res_ari_asterisk.so module

cdc*CLI> module load res_ari_asterisk.so
Loaded res_ari_asterisk.so
 Loaded res_ari_asterisk.so => (RESTful API module - Asterisk resources)

and now i receive the json back!

{
  "build": {
    "os": "Linux",
    "kernel": "4.4.0-101-generic",
    "machine": "x86_64",
    "options": "COMPILE_DOUBLE, OPTIONAL_API",
    "date": "2018-01-25 09:50:29 UTC",
    "user": "makerpms"
  },
  "system": {
    "version": "13.17.2",
    "entity_id": "02:00:00:5b:b3:46"
  },
  "config": {
    "name": "",
    "default_language": "en",
    "setid": {
      "user": "",
      "group": ""
    }
  },
  "status": {
    "startup_time": "2018-06-11T19:58:50.797+0200",
    "last_reload_time": "2018-06-27T18:12:40.621+0200"
  }
}

Yeah!

Tomorrow i try with other modules to test the other rest api calls…


(Stefano Fancello) #5

:smiley: :clap:

We use it for NethCTI, a web application that shows current calls, presence, queues, allows WebRTC calls …


(Alessandro) #6

Interesting, i used nethCTI in my previous work (I did not realize you were part of the development team!!!).
I have to make 2% of what makes nethCTI! :smiley:

NethCTI is good, but isn’t open! :stuck_out_tongue:

however, Ari now works.
But i need to know how to use statis…
I can not find exhaustive documentation.


(Stefano Fancello) #7

I wrote everything I knew :rofl:

On github there are libraries to use ARI, like this one https://github.com/asterisk/ari-py


(Alessandro) #8

I’ll try! Even if you read to the side that the last change was 5 years ago it’s sad!

I want to try ari4java…but python seems quickest…