This is an old revision of the document!
Distribute Asterisk Events using XMPP PubSub
On occasion it is desirable to distribute device state and message waiting indication (MWI) events between Asterisk servers. This can be accomplished by utilizing XMPP PubSub events and a common XMPP server. The Asterisk XMPP clients are configured via either jabber.conf
or xmpp.conf
.
Note: AstLinux 1.1.3 or later is required
Configure Local Server1
Snippet - Asterisk jabber.conf
or xmpp.conf
on Local Server1
[general] ;debug=yes ;autoprune=yes autoregister=yes ;collection_nodes=yes pubsub_autocreate=yes [asterisk] type=client serverhost=localhost ; ie. asterisk.mydomain.tld pubsub_node=pubsub.asterisk.mydomain.tld username=server1@asterisk.mydomain.tld secret=password ;priority=1 ;port=5222 usetls=yes usesasl=yes buddy=server2@asterisk.mydomain.tld distribute_events=yes
XMPP server configuration on Local Server1
The AstLinux Web Interface is used for configuration, click on Configure XMPP
Network tab → Network Services:
Specify the matching DNS hostname for your local server1…
Define the PubSub options…
Tip -> More Info: XMPP Server Configuration
Tip -> The firewall on the XMPP Server1 box must allow TCP port 5222 for Server2 to connect.
Snippet - extensions.conf
on Local Server1
; DEVICE_STATE hint example [blf] exten => 24,hint,SIP/24
Configure Remote Server2
Snippet - Asterisk jabber.conf
or xmpp.conf
on Remote Server2
[general] ;debug=yes ;autoprune=yes autoregister=yes ;collection_nodes=yes pubsub_autocreate=yes [asterisk] type=client serverhost=asterisk.mydomain.tld pubsub_node=pubsub.asterisk.mydomain.tld username=server2@asterisk.mydomain.tld secret=password ;priority=1 ;port=5222 usetls=yes usesasl=yes buddy=server1@asterisk.mydomain.tld distribute_events=yes
Snippet - extensions.conf
on Remote Server2
; DEVICE_STATE hint example [blf_server1] exten => 1024,hint,SIP/24
Note -> Only the device state (INUSE, NOT_INUSE, RINGING) of “SIP/24” is distributed, not the hintname (e.g. “1024”) or the context (e.g. “blf_server1”). You can name the hint and context as you want on Server2.
Now you can simply create a BLF key on a phone on Server2 for “1024” to monitor the device state of “SIP/24” of Server1. The context (e.g. “blf_server1”) must be “reachable” for the phone though. It can be included into your “default” context (or whatever your main context for your local phones is), or you can set a “subscribecontext” in sip.conf
.
The Message Waiting Indication (MWI) events are also distributed across servers. (Request for working example.)