1

I've recently upgraded our PBX to Asterisk 13, in the hope that the new REST API and WebSockets support would solve some problems we were having with tracking calls via the AMI.

We're building a C# application that will sit in the Windows tool tray and bring up information based on caller ID by querying our CRM whenever a user makes or receives a call.

Can someone clarify if it's possible via WS to subscribe to a WS channel that reports all (or even just extension specific) events taking place on the PBX?

In terms of progress made so far, I've used Swagger to explore the ARI, and the channel information given back via the channel endpoint (e.g. http://10.0.0.1:8088/ari/channels?api_key=admin:secret) looks perfect:

[
  {
    "id": "1466860766.240522",
    "name": "PJSIP/905-00000c74",
    "state": "Ring",
    "caller": {
      "name": "",
      "number": "020xxx"
    },
    "connected": {
      "name": "CID:020xxx",
      "number": "07xxx"
    },
    "accountcode": "",
    "dialplan": {
      "context": "macro-dialout-trunk",
      "exten": "s",
      "priority": 22
    },
    "creationtime": "2016-06-25T14:19:26.040+0100",
    "language": "en"
  },
  {
    "id": "1466860766.240524",
    "name": "SIP/siptrunk-000003fc",
    "state": "Down",
    "caller": {
      "name": "CID:02033554047",
      "number": "07xxx"
    },
    "connected": {
      "name": "",
      "number": "020xxx"
    },
    "accountcode": "",
    "dialplan": {
      "context": "ext-did",
      "exten": "07xxx",
      "priority": 1
    },
    "creationtime": "2016-06-25T14:19:26.264+0100",
    "language": "en"
  }
]

That channel information gives us everything we need in a concise, easy to digest format - PJSIP channel (i.e. the extension), state, outgoing trunk CID, and outbound number being dialled.

However, the /events endpoint as far as I can see depends on you creating an 'application' within Asterisk (from what I can gather like a conference or such?) - and despite two days of trying various things using wscat and reading documentation I can't see any way whereby you can subscribe to a WS channel that will give you all events back similar to the JSON above.

Am I misunderstanding the intentions behind WS support with Asterisk 13? Is it not meant for this purpose? Is there a better way to achieve my aim without polling /channels? Any help/pointers appreciated.

iam
  • 137
  • 4
  • 12

1 Answers1

1

I think that Asterisk WebSockets support is intended for interop between WebRTC browser and Asterisk. It's common to use WebSockets to transport SIP messages from web-browser (look at the SIPml and JSSip). So, it's not ami replacement.

Update: it seems that now Asterisk use websockets for ARI also, so my initial suggestion is wrong, sorry. So, according to another stack overflow question you should use 'application'.

Community
  • 1
  • 1
user1802474
  • 106
  • 1
  • 7
  • Thanks for the reply - I'd seen that link, but it doesn't really help as far as I can see - it relies on you actually configuring a dialplan application? Looking at the example given: POST https://localhost:8080/ari/applications/my_app/subscription?eventSource=endpoint:PJSIP%2FAlice That would suggest I need to have an application (my_app) in the dialplan, such as a conference? – iam Jun 29 '16 at 15:16