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 :