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

Daniel Jenkins dan.jenkins88 at gmail.com
Thu Oct 24 04:38:05 CDT 2013


On Wed, Oct 23, 2013 at 11:08 PM, Paul Belanger <
paul.belanger at polybeacon.com> wrote:

> 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
>
> _______________________________________________
> asterisk-app-dev mailing list
> asterisk-app-dev at lists.digium.com
> http://lists.digium.com/cgi-bin/mailman/listinfo/asterisk-app-dev
>

Just adding my 2 cents as we talked about this on IRC the other day,

Seems like adding this wouldn't be difficult (my limited knowledge of
stasis etc), but I'm not sure if we should just go adding transports
because we can...

Server Sent events are a proposed spec and have not been formalised.

I don't see an issue using Websockets, it's a nice, structured way of
getting data, and we may, one day, use the two way comms available to us,
if this happened, then you'd have Server Sent events, websockets and HTTP
REST API

Websockets have nice libs in *most* langs now, so they can be consumed very
easily.

My biggest issue with SSE is that it's a draft and could completely change,
and that's not good for something like Asterisk, it's fine for something
that isn't released as a product people will be using in 3 years when
standards have moved on. Websockets have an RFC.

We did talk in the IRC chat about how the docs are a little misleading, as
it lists /events in the API docs when it's not really a REST endpoint; so
maybe we could improve that.

Dan
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.digium.com/pipermail/asterisk-app-dev/attachments/20131024/84933707/attachment.html>


More information about the asterisk-app-dev mailing list