Re: ARI ApplicationStarted or how to know that WebSocket connection established?

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Sep 25, 2014 at 5:17 PM, Maxim Litnitskiy
<litnimaxster@xxxxxxxxx> wrote:
>
> 2014-09-25 18:29 GMT+04:00 Matthew Jordan <mjordan@xxxxxxxxxx>:
>>

<snip>

I don't think I fully understand your reply, but I'll do my best to
answer your questions.

> Matt, thanks for your reply.
> Seems I was not clear enough.
> Yes Asterisk knows when smth is able to handle the Stasis application.
> And when I do a connection I also know.
> Know what?

A Stasis application is activated when a client makes a WebSocket
connection indicating that it wants to handle events from that
application. For example:

wscat -c "ws://localhost:8088/ari/events?api_key=asterisk:asterisk&app=hello-world"

Indicates that a WebSocket connection is being established to handle
the Stasis application 'hello-world'. When the connection is made, the
application is activated. At that point in time, any channel that
enters into the dialplan application Stasis will be handed over to the
external client (it now "owns" the channel), which is indicated by the
StasisStart event.

> You mean that client.connect(...) success call is enouth? After it returns
> Stasis app is setup in asterisk?

Yes.

Experiment and try it:

(1) Don't connect a WebSocket. Have the following in your dialplan:

exten => 1000,1,Stasis(hello-world)

(2) Originate a channel to 1000. Asterisk will reject it as the Stasis
application is not activated, i.e., there is no WebSocket to handle
the events from the application.

(3) Connect a WebSocket, specifying 'hello-world' as the application.

(4) Originate a channel again. You should get a StasisStart event for
that channel.

> And this mean I have to signal to other thread exactly after exit from
> client.connect(..)?

If your WebSocket connection is broken, how are you going to handle
changes to the state of a channel? Your application no longer knows -
for sure - whether or not someone has hung up a channel in your Stasis
application.

Now, Asterisk is a *tad* forgiving in this regard. Once a WebSocket
connection has been established for an application, if it is broken,
Asterisk will consider the Stasis application to be in a 'whoops,
that's broken' state. It will issue WARNINGS about events getting
missed. It will keep the application going, however, until the
WebSocket connection re-establishes.

Matt

-- 
Matthew Jordan
Digium, Inc. | Engineering Manager
445 Jan Davis Drive NW - Huntsville, AL 35806 - USA
Check us out at: http://digium.com & http://asterisk.org

_______________________________________________
asterisk-app-dev mailing list
asterisk-app-dev@xxxxxxxxxxxxxxxx
http://lists.digium.com/cgi-bin/mailman/listinfo/asterisk-app-dev




[Index of Archives]     [Asterisk SS7]     [Asterisk Announcements]     [Asterisk Users]     [PJ SIP]     [Linux ARM Kernel]     [Linux ARM]     [Linux Omap]     [Fedora ARM]     [IETF Annouce]     [Security]     [Bugtraq]     [Linux]     [Linux OMAP]     [Linux MIPS]     [ECOS]     [Linux API]

  Powered by Linux