Implementing PJSIP Device State Exchange

Im looking to setup distributed device state using PJSIP method, but I cant seem to find anyone who can really explain it to me. I have read the page and looked over the code snip-its but have no idea how to actually implement it and was hoping someone could point me in the right direction.

Just to give the background here:
I have (3) FreePBX servers running at three separate geographical locations all connected with MetroE. I currently use a centralized mailbox server shared among the three locations. The three locations pass internal calls over IAX trunks, and external calls go out using SIP trunks directly from the site placing the call. All of my endpoints are currently configured using the CHAN_SIP driver.

  • Will I have to migrate all of my endpoints over from CHAN_SIP to PJSIP in order to use this functionality?

  • I added the basic code from the asterisk site (link below) to my pjsip.conf files and updates the IP addresses for my enviorment, but what actually triggers this code to run, how does asterisk know to use it?

https://wiki.asterisk.org/wiki/display/AST/Exchanging+Device+and+Mailbox+State+Using+PJSIP

No, PJSIP is used as the transport mechanism for the messages - endpoints donā€™t factor into that. The act of configuring it causes it to exchange the information. I have to also say that it hasnā€™t been tested or used with FreePBX, they may use things in different ways to cause it to not work.

Si I should be able to drop that sample config directly into my pjsip.conf file on each end, update the IPā€™s, and thatā€™s all it takes?

Now this doesnt require any type of weird mapping or a PJSIP trunk between the sites does it?

And just so I can say I asked, how does asterisk on system B track the extensions from System A when they donā€™t technically exist on system B?

There is no such thing as a ā€œtrunkā€ in PJSIP, thereā€™s just configuration to allow packets to be sent and for a source to be correctly identified which the config does. It also doesnā€™t track extensions, it exchanges device state. That is: It sends a message for example saying ā€œSIP/bob is ringingā€ from one to the other, that gets turned into an event, if anything cares about it then they react (like the dialplan cares if a hint is defined), if nothing does then nothing happens.

1 Like

Yes, and iā€™m trying to setup distributed device state so that the receptionist at site A can see the state of extensions at my other locations. Currently when I setup a BLF for an extension outside of the phones site, the light stays blank because it cant find the line to subscribe to, however if I setup a BLF for an extension within the same system it works fine even without this setup as expectedā€¦

I personally donā€™t have a clue where to ever start looking at this.

The wiki page is how to exchange it, but you will still need to place a hint in the dialplan to say dialplan extension ā€˜1000ā€™ is ā€˜SIP/bobā€™ for example, just like normal.

You could also you AMI event DeviceStateChange to monitor devices state over the network

https://wiki.asterisk.org/wiki/display/AST/Asterisk+16+ManagerEvent_DeviceStateChange
You will get ouput like this

0 : Event: DeviceStateChange
1 : Privilege: call,all
2 : Device: PJSIP/6000
3 : State: RINGING
4 :
5 :
0 : Event: DeviceStateChange
1 : Privilege: call,all
2 : Device: PJSIP/6001
3 : State: INUSE
4 :
5 :
0 : Event: DeviceStateChange
1 : Privilege: call,all
2 : Device: PJSIP/6000
3 : State: NOT_INUSE
4 :
5 :
0 : Event: DeviceStateChange
1 : Privilege: call,all
2 : Device: PJSIP/6001
3 : State: NOT_INUSE
4 :