[asterisk-dev] device_state distribution issues

Russell Bryant russell at digium.com
Mon Nov 8 16:31:02 CST 2010


On Mon, 2010-11-08 at 23:02 +0100, Klaus Darilion wrote:
> Russell Bryant wrote:
> > On Mon, 2010-11-08 at 10:56 -0600, Kevin P. Fleming wrote:
> >> On 11/08/2010 06:12 AM, Klaus Darilion wrote:
> >>
> >>> Does Asterisk keep proper state of remote devices (e.g. with a call 
> >>> timeout)? If yes, then it is a bug. If no - then it would explain this 
> >>> behavior but IMO would be a serious limitation.
> >> I suspect you may be trying to do something that is not yet supported:
> >> to my knowledge, the device state distribution that exists today is to
> >> allow a device that is managed by *one* server to be visible to other
> >> servers, so they can make decisions based on its state. It does not
> >> support *multi-master* mode, where multiple servers are involved in
> >> computing the state of a single device. For that to be possible, there
> >> would have to be some 'owner' of the device to consolidate the
> >> information from the servers involved.
> > 
> > In the case of res_ais, it works by having every server report state
> > changes that occur on that server.  The result is that each server has
> > an internal table of the state of each device from the perspective on
> > each server involved.  When the state changes on _any_ server, it then
> > looks at the last known state of that device on all servers and
> > determines an overall state.  So, based on that, this is supposed to
> > work.
> 
> Ok. I will try to find some time to test with AIS.
> 
> > The way this works is that each event is tagged with a server ID
> > (referred to as an entity ID, or EID).  From a quick look at the XMPP
> > implementation, it appears that the server ID is not being propagated.
> > So, the failure you are seeing is not ideal (a bug actually, please
> > report it), but it is the expected behavior right now.
> 
> Here is the trace of an event sent from Asterisk to the XMPP server:
> 
> 
> <iq to='pubsub.armani.labs.nic.at' 
> from='armani_asterisk at armani.labs.nic.at/asterisk' type='set' id='aaald'>
>   <pubsub xmlns='http://jabber.org/protocol/pubsub'>
>    <publish node='device_state'>
>     <item id='SIP/klaus0'>
>      <state xmlns='http://asterisk.org' 
> eid='00:16:3e:e4:77:12'>INUSE</state>
>     </item>
>    </publish>
>   </pubsub>
> </iq>
> 
> As you see there is an eid transmitted. If I can read the trace 
> correctly it seems that the published event is sent from the XMPP server 
> to all subscribed Asterisk server - even the one which published the event.
> 
> Takeing a look at the code shows that the eid is used in res_jabber, at 
> least to filter out the own events:
> 
> aji_handle_pubsub_event(...) {
>    ...
>    ast_str_to_eid(&pubsub_eid, iks_find_attrib(item_content, "eid"));
>    if (!ast_eid_cmp(&ast_eid_default, &pubsub_eid)) {
>      ast_log(LOG_DEBUG, "Returning here, eid of incoming event matches 
> ours!\n");
>      return IKS_FILTER_EAT;
>    }
>    ...
> 
> > The XMPP distributed device state code needs to be updated such that the
> > EID information element is included in state changes that it sends out
> > such that its behavior matches that of the AIS implementation.
> 
> As shown above it is already sent out and used for filtering, probably 
> it misses keeping of the remote state.

Thanks for the analysis!

In that case, what it's probably missing is copying the EID from the
PubSub event into the ast_event it creates before passing it into the
Asterisk core for processing.

-- 
Russell Bryant
Digium, Inc.  |  Engineering Manager, Open Source Software
445 Jan Davis Drive NW   -    Huntsville, AL 35806  -  USA
jabber: rbryant at digium.com    -=-    skype: russell-bryant
www.digium.com -=- www.asterisk.org -=- blogs.asterisk.org





More information about the asterisk-dev mailing list