Listen To ARI Events

Home » Asterisk Users » Listen To ARI Events
Asterisk Users 8 Comments

I have the ARI enabled on my Asterisk test box, and want to listen to all events. I can’t find the syntax to do that. Can I only listen to events related to a stasis app?

I was hoping that a simple wscat command like this would show me all events:

wscat -c “ws://localhost:8088/ari/events?api_key=asterisk:asterisk “

I know how to do it form the AMI.looking for something similar.

Thanks

Brian

(Ast newbie)

8 thoughts on - Listen To ARI Events

  • I tried the command below (with subscribeAll=yes). I made a couple of calls but didn’t see any events. Should I see events?

    From: asterisk-users [mailto:asterisk-users-bounces@lists.digium.com] I have the ARI enabled on my Asterisk test box, and want to listen to all events. I can’t find the syntax to do that. Can I only listen to events related to a stasis app?

    I was hoping that a simple wscat command like this would show me all events:

    wscat -c “ws://localhost:8088/ari/events?api_key=asterisk:asterisk “

    This does not listen to all events by default. If you want to listen to everything you can pass subscribeAll=yes[1] like so:

    ws://localhost:8088/ari/events?api_key=asterisk:asterisk&subscribeAll=yes

    [1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+20+Events+REST+API#Asterisk20EventsRESTAPI-userEvent

  • I’ve reread the documentation a few times, and what isn’t clear is whether I need an app=X parameter in the url. In other words, can I only get events for a single named statis app? Or can I get events for the entire Asterisk server?

    The command below (without app= parameter) results in no events being shown, but no error either.

    Thanks

    Brian

    (Ast newbie)

    From: asterisk-users [mailto:asterisk-users-bounces@lists.digium.com] I have the ARI enabled on my Asterisk test box, and want to listen to all events. I can’t find the syntax to do that. Can I only listen to events related to a stasis app?

    I was hoping that a simple wscat command like this would show me all events:

    wscat -c “ws://localhost:8088/ari/events?api_key=asterisk:asterisk “

    This does not listen to all events by default. If you want to listen to everything you can pass subscribeAll=yes[1] like so:

    ws://localhost:8088/ari/events?api_key=asterisk:asterisk&subscribeAll=yes

    [1] https://wiki.asterisk.org/wiki/display/AST/Asterisk+20+Events+REST+API#Asterisk20EventsRESTAPI-userEvent

  • You must specify an app as well. If you don’t, it should reply with a 400. If it’s not… then are you connecting to Asterisk? What does the console say? For example I did the following:

    wscat –connect
    “ws://kappa:8088/ari/events?api_key=asterisk:asterisk&subscribeAll=yes&app=test”

    Which connected successfully and then I did a call which resulted in:

    {“type”:”ChannelCreated”,”timestamp”:”2023-06-07T10:54:56.295-0300″,”channel”:{“id”:”1686146096.1″,”name”:”PJSIP/mytrunk_endpoint-00000000″,”state”:”Down”,”protocol_id”:””,”caller”:{“name”:”Electron”,”number”:”1009″},”connected”:{“name”:””,”number”:””},”accountcode”:””,”dialplan”:{“context”:”from-external”,”exten”:”s”,”priority”:1,”app_name”:””,”app_data”:””},”creationtime”:”2023-06-07T10:54:56.295-0300″,”language”:”en”},”asterisk_id”:”0c:c4:7a:ba:b3:5a”,”application”:”test”}
    < {"type":"ChannelDialplan","timestamp":"2023-06-07T10:54:56.295-0300","dialplan_app":"AppDial2","dialplan_app_data":"(Outgoing Line)","channel":{"id":"1686146096.1","name":"PJSIP/mytrunk_endpoint-00000000","state":"Down","protocol_id":"d89ddae0-6568-4ab4-995b-8feb39366a58","caller":{"name":"Electron","number":"1009"},"connected":{"name":"","number":""},"accountcode":"","dialplan":{"context":"from-external","exten":"s","priority":1,"app_name":"AppDial2","app_data":"(Outgoing Line)"},"creationtime":"2023-06-07T10:54:56.295-0300","language":"en"},"asterisk_id":"0c:c4:7a:ba:b3:5a","application":"test"} < {"type":"Dial","timestamp":"2023-06-07T10:54:56.295-0300","dialstatus":"","forward":"","dialstring":"mytrunk_endpoint","peer":{"id":"1686146096.1","name":"PJSIP/mytrunk_endpoint-00000000","state":"Down","protocol_id":"d89ddae0-6568-4ab4-995b-8feb39366a58","caller":{"name":"Electron","number":"1009"},"connected":{"name":"","number":""},"accountcode":"","dialplan":{"context":"from-external","exten":"s","priority":1,"app_name":"AppDial2","app_data":"(Outgoing Line)"},"creationtime":"2023-06-07T10:54:56.295-0300","language":"en"},"asterisk_id":"0c:c4:7a:ba:b3:5a","application":"test"} < {"cause":34,"type":"ChannelHangupRequest","timestamp":"2023-06-07T10:54:56.296-0300","channel":{"id":"1686146096.1","name":"PJSIP/mytrunk_endpoint-00000000","state":"Down","protocol_id":"d89ddae0-6568-4ab4-995b-8feb39366a58","caller":{"name":"Electron","number":"1009"},"connected":{"name":"","number":""},"accountcode":"","dialplan":{"context":"from-external","exten":"s","priority":1,"app_name":"AppDial2","app_data":"(Outgoing Line)"},"creationtime":"2023-06-07T10:54:56.295-0300","language":"en"},"asterisk_id":"0c:c4:7a:ba:b3:5a","application":"test"} < {"type":"Dial","timestamp":"2023-06-07T10:54:56.296-0300","dialstatus":"CONGESTION","forward":"","dialstring":"mytrunk_endpoint","peer":{"id":"1686146096.1","name":"PJSIP/mytrunk_endpoint-00000000","state":"Down","protocol_id":"d89ddae0-6568-4ab4-995b-8feb39366a58","caller":{"name":"Electron","number":"1009"},"connected":{"name":"","number":""},"accountcode":"","dialplan":{"context":"from-external","exten":"s","priority":1,"app_name":"AppDial2","app_data":"(Outgoing Line)"},"creationtime":"2023-06-07T10:54:56.295-0300","language":"en"},"asterisk_id":"0c:c4:7a:ba:b3:5a","application":"test"} < {"type":"ChannelDestroyed","timestamp":"2023-06-07T10:54:56.296-0300","cause":34,"cause_txt":"Circuit/channel congestion","channel":{"id":"1686146096.1","name":"PJSIP/mytrunk_endpoint-00000000","state":"Down","protocol_id":"d89ddae0-6568-4ab4-995b-8feb39366a58","caller":{"name":"Electron","number":"1009"},"connected":{"name":"","number":""},"accountcode":"","dialplan":{"context":"from-external","exten":"s","priority":1,"app_name":"AppDial2","app_data":"(Outgoing Line)"},"creationtime":"2023-06-07T10:54:56.295-0300","language":"en"},"asterisk_id":"0c:c4:7a:ba:b3:5a","application":"test"}

  • Ok that worked.

    Since I have not declared a statis app called “test”, does that mean any non-existent app name on the URL will subscribe to all system events? (Or is test a built-in app name)

    Brian

    From: asterisk-users [mailto:asterisk-users-bounces@lists.digium.com] I’ve reread the documentation a few times, and what isn’t clear is whether I need an app=X parameter in the url. In other words, can I only get events for a single named statis app? Or can I get events for the entire Asterisk server?

    The command below (without app= parameter) results in no events being shown, but no error either.

    You must specify an app as well. If you don’t, it should reply with a 400. If it’s not… then are you connecting to Asterisk? What does the console say? For example I did the following:

    wscat –connect “ws://kappa:8088/ari/events?api_key=asterisk:asterisk&subscribeAll=yes&app=test”

    Which connected successfully and then I did a call which resulted in:

    {“type”:”ChannelCreated”,”timestamp”:”2023-06-07T10:54:56.295-0300″,”channel”:{“id”:”1686146096.1″,”name”:”PJSIP/mytrunk_endpoint-00000000″,”state”:”Down”,”protocol_id”:””,”caller”:{“name”:”Electron”,”number”:”1009″},”connected”:{“name”:””,”number”:””},”accountcode”:””,”dialplan”:{“context”:”from-external”,”exten”:”s”,”priority”:1,”app_name”:””,”app_data”:””},”creationtime”:”2023-06-07T10:54:56.295-0300″,”language”:”en”},”asterisk_id”:”0c:c4:7a:ba:b3:5a”,”application”:”test”}
    < {"type":"ChannelDialplan","timestamp":"2023-06-07T10:54:56.295-0300","dialplan_app":"AppDial2","dialplan_app_data":"(Outgoing Line)","channel":{"id":"1686146096.1","name":"PJSIP/mytrunk_endpoint-00000000","state":"Down","protocol_id":"d89ddae0-6568-4ab4-995b-8feb39366a58","caller":{"name":"Electron","number":"1009"},"connected":{"name":"","number":""},"accountcode":"","dialplan":{"context":"from-external","exten":"s","priority":1,"app_name":"AppDial2","app_data":"(Outgoing Line)"},"creationtime":"2023-06-07T10:54:56.295-0300","language":"en"},"asterisk_id":"0c:c4:7a:ba:b3:5a","application":"test"} < {"type":"Dial","timestamp":"2023-06-07T10:54:56.295-0300","dialstatus":"","forward":"","dialstring":"mytrunk_endpoint","peer":{"id":"1686146096.1","name":"PJSIP/mytrunk_endpoint-00000000","state":"Down","protocol_id":"d89ddae0-6568-4ab4-995b-8feb39366a58","caller":{"name":"Electron","number":"1009"},"connected":{"name":"","number":""},"accountcode":"","dialplan":{"context":"from-external","exten":"s","priority":1,"app_name":"AppDial2","app_data":"(Outgoing Line)"},"creationtime":"2023-06-07T10:54:56.295-0300","language":"en"},"asterisk_id":"0c:c4:7a:ba:b3:5a","application":"test"} < {"cause":34,"type":"ChannelHangupRequest","timestamp":"2023-06-07T10:54:56.296-0300","channel":{"id":"1686146096.1","name":"PJSIP/mytrunk_endpoint-00000000","state":"Down","protocol_id":"d89ddae0-6568-4ab4-995b-8feb39366a58","caller":{"name":"Electron","number":"1009"},"connected":{"name":"","number":""},"accountcode":"","dialplan":{"context":"from-external","exten":"s","priority":1,"app_name":"AppDial2","app_data":"(Outgoing Line)"},"creationtime":"2023-06-07T10:54:56.295-0300","language":"en"},"asterisk_id":"0c:c4:7a:ba:b3:5a","application":"test"} < {"type":"Dial","timestamp":"2023-06-07T10:54:56.296-0300","dialstatus":"CONGESTION","forward":"","dialstring":"mytrunk_endpoint","peer":{"id":"1686146096.1","name":"PJSIP/mytrunk_endpoint-00000000","state":"Down","protocol_id":"d89ddae0-6568-4ab4-995b-8feb39366a58","caller":{"name":"Electron","number":"1009"},"connected":{"name":"","number":""},"accountcode":"","dialplan":{"context":"from-external","exten":"s","priority":1,"app_name":"AppDial2","app_data":"(Outgoing Line)"},"creationtime":"2023-06-07T10:54:56.295-0300","language":"en"},"asterisk_id":"0c:c4:7a:ba:b3:5a","application":"test"} < {"type":"ChannelDestroyed","timestamp":"2023-06-07T10:54:56.296-0300","cause":34,"cause_txt":"Circuit/channel congestion","channel":{"id":"1686146096.1","name":"PJSIP/mytrunk_endpoint-00000000","state":"Down","protocol_id":"d89ddae0-6568-4ab4-995b-8feb39366a58","caller":{"name":"Electron","number":"1009"},"connected":{"name":"","number":""},"accountcode":"","dialplan":{"context":"from-external","exten":"s","priority":1,"app_name":"AppDial2","app_data":"(Outgoing Line)"},"creationtime":"2023-06-07T10:54:56.295-0300","language":"en"},"asterisk_id":"0c:c4:7a:ba:b3:5a","application":"test"}

  • Applications are not declared or configured anywhere. The act of connecting a websocket with an app name creates them. And no, you have to pass subscribeAll=yes to have the websocket subscribed to all events.

  • I’ve been looking through the docs (near https://wiki.asterisk.org/wiki/display/AST/Asterisk+20+Applications+REST+API) and am searching for a list of events I can subscribe to. Is this list published? Or can I query the ARI for a list of available events?

    Thanks

    Brian

    From: asterisk-users [mailto:asterisk-users-bounces@lists.digium.com] Ok that worked.

    Since I have not declared a statis app called “test”, does that mean any non-existent app name on the URL will subscribe to all system events? (Or is test a built-in app name)

    Applications are not declared or configured anywhere. The act of connecting a websocket with an app name creates them. And no, you have to pass subscribeAll=yes to have the websocket subscribed to all events.