[Apologies for replying to the digest, seems like it's digest-only or all messages directly? Responding inline.] 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. >> > I'm not suggesting to add interfaces, I'm requesting that the interfaces you already implement should each expose the complete API. See below... > >> 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 >> > To be clear, SSE is a side detail. The main point is that HTTP is fully capable of streaming events, without requiring polling. For instance CouchDB doesn't use SSE, but it still exposes an HTTP REST endpoint that streams events. SSE is about a particular browser api, and a specific format for the events to be written in. >> -- >> 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... > I'm not suggesting to add new transports. I'm suggesting that whichever transports you support, should implement the full API. Apparently you've already chosen to support both HTTP and websockets. > Server Sent events are a proposed spec and have not been formalised. > See above, SSE is just a detail, the point is that events can be sent with HTTP REST. > > 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 > SSE is not an alternative to a REST API, it's an implementation detail of an "events" REST endpoint. The main point is simply that there should be an events REST (=HTTP) endpoint. Second, it would be great if it didn't require polling (so stream chunks). Third, it would be extra icing on the cake, if those chunks would be in SSE format. There's one really cool thing in SSE that I don't know whether websockets supports out of the box: If the client goes offline, when it goes back online it can tell the server the last event id it knows about, and the server can send it all the events that it missed. > > Websockets have nice libs in *most* langs now, so they can be consumed > very easily. > Look, if you would have a complete websockets API I would have no complaint. :) What I don't like is that part of the API is done as REST, and the other part is done as websockets. Wouldn't it make more sense, that whatever technology or technologies you use to expose the API, exposes the complete API? > > 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. > You don't have to claim that you're adhering to the SSE standard (see above)... > > 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 > > Thanks! -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.digium.com/pipermail/asterisk-app-dev/attachments/20131024/a4bb1fc7/attachment.html>