Check device state of pjsip account on asterisk2 from asterisk1

i have 2 asterisk servers:
asterisk1 and asterisk2

what i am trying to do is to check the device state of an account on asterisk2 from dialplan of asterisk1.

what is known that you can check the device state of the accounts on the same asterisk server.
for example if there is a sip account 3700 on asterisk1
then on dialplan of asterisk1 you check the device state(checking for busy only now) of this account by:

exten => _X,1,GOTOIF(["{DEVICE_STATE(PJSIP/${EXTEN})}" = “BUSY”]?devBusy:devNotBusy)

this command allows me to do so.

but what i am trying to do now is to check the device state of an account on asterisk2 from asterisk1 (asterisk1 and asterisk2 are connected by a trunk called asterisktrunk )

so what i tried to do is :

exten => _X,1,GOTOIF(["{DEVICE_STATE(PJSIP/${EXTEN}@asterisktrunk)}" = “BUSY”]?devBusy:devNotBusy)



but it always gives INVALID as if it is an unknown extension …

so what should i do ?

thanks in advance
best regards

hello,

you have to configure PJSIP Publishing Extension State permit you to connect two or more Asterisk PBX to known the stat of each extension configured:

Regards

1 Like

thank you very much @annusfictus

i believe this is very useful but honestly i still dont know how to use but this is what i understood:

in pjsip.conf at asterisk2 i should add

[test-esc]
type=outbound-publish
server_uri=sip:ip of asterisk1
from_uri=sip:ip of asterisk2
event=dialog
multi_user=yes

@body=application/dialog-info+xml
@context=^users
@exten=4700 which is the extension that i need to be published

this way from asterisk1 i can read the device state of 4700 that is at asterisk2 by adding at extension.conf of asterisk1 a command which i still dont know yet what it is !!!

i need some help with it

thanks in advance

Why just dont use AMI ?

1 Like

helo @ambiorixg12,

honestly i have never used AMI commands and i am not familiar to it.
but i assume you mean that there is an AMI command that allows me to check the device state of an account on asterisk2 from asterisk1 before making the call ?
i would appreciate your help.

best regards

I think he means there is an AMI command that allows asterisk2 to check a device state on asterisk2. The AMI client can be anywhere, and doesn’t have to be on a machines that is even capable of running Asterisk, but the assumption here will be that it is on the machine running asterisk1.

1 Like

Yes i believe he misunderstood me …
Thanks david

After read your requirement again, instead of use the DEVICE_STATE() function or AMI try ChanIsAvail, to check the peer state before dial

https://wiki.asterisk.org/wiki/display/AST/Asterisk+16+Application_ChanIsAvail

The core requirement is to access the information from a different machine.

1 Like

Here’s an example how to do it with FreePBX https://wiki.freepbx.org/display/FDT/Remote+BLF’s+using+PJSIP

Once you can monitor the hints on both servers you should be able to use the same dialplan logic you posted above.

3 Likes

Yes i believe this is the proper solution …
I am very grateful @PitzKey

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.