[asterisk-app-dev] Request regarding ARI REST APIs

Paul Belanger paul.belanger at polybeacon.com
Wed Oct 23 17:08:08 CDT 2013


On Wed, Oct 23, 2013 at 5:27 PM, Naftoli Gugenheim <naftoligug at gmail.com> wrote:
> Hello. I am very excited about Asterisk 12 and ARI.
>
> I noticed on the wiki that while most of the API endpoints (used to talk
> *to* asterisk) are true REST, using HTTP, the events endpoint would actually
> use websockets, not HTTP. Many people don't realize it, but although
> websockets is often associated with "server push," HTML5 introduces another
> way to do server push efficiently, that works over HTTP, namely
> SSE/EventSource. (See e.g.
> http://www.html5rocks.com/en/tutorials/eventsource/basics/.) Although the
> basic idea is nothing new; for instance CouchDB lets you watch events
> streamed over HTTP
> (http://guide.couchdb.org/draft/notifications.html#continuous). Websockets
> are a much more powerful protocol, allowing for 2-way communication inline.
>
> In some scenarios it may require more setup for application developers to
> access websockets. For instance some platforms don't have the capability
> built in and require adding a third-party dependency.
> I would therefore like to request that you expose an HTTP endpoint that
> streams events in a connection that can be kept open, preferably using the
> SSE format.
>
> Another argument that can be made, is that REST and websockets are two
> different protocols. Instead of implementing the API half in one protocol
> and half in another, why not have a complete REST API, *and* a complete
> websockets API? After all, websockets are 2-way, so why not let websocket
> users send commands to asterisk through it as well?
>
Well, if I understand properly, now that the stasis bus is there,
adding different interfaces shouldn't be to difficult. However, I'm
not sure I'd want to see Asterisk try and implement every possible way
to do this.

That said, I'm in the process of figuring out how to handle the event
now too. Right now, using python-ari (tornado), I have a websocket
open streaming events from ARI. I'm thinking that I'd then take said
events and drop them into AMQP and moving them back to the core of my
applications.  As I bring a new asterisk nodes online, I simple fire
up the WS / AMPQ wrapper and go from there.

I'm not too familiar with SSE, but assuming something like tornado
support them, it wouldn't be too hard to add them into the python
library

-- 
Paul Belanger | PolyBeacon, Inc.
Jabber: paul.belanger at polybeacon.com | IRC: pabelanger (Freenode)
Github: https://github.com/pabelanger | Twitter: https://twitter.com/pabelanger



More information about the asterisk-app-dev mailing list