DEVICE_STATE output is NOT_INUSE with PJSIP conf

Hello

I want to detect my endpoint status
I am using DEVICE_STATE dialplan function with PJSIP
I am getting return DEVICE_STATE output NOT_INUSE
In old version I saw that callcounter parameter sould by YES

Witch parameter I need to add to my PJSIP conf ?

attached my PJSIP configuration
[KAMnet_TST1]
type=endpoint
transport=transport-udp1
context=app-router
disallow=all
allow=alaw
dtmf_mode=auto
aors=KAMnet_TST1
direct_media=no

[KAMnet_TST1]
type=aor
contact=sip:10.25.153.150:5060;user=phone
qualify_frequency=10

[KAMnet_TST1]
type=identify
endpoint=KAMnet_TST
match=10.25.153.150

PJSIP does not have the same option, it’s always enabled. The only option which controls device state is device_state_busy_at which controls the number of channels before the device is considered busy.

Hi
Thank you for your answer!!

If it’s always enabled like you told me
Can you please help me to understand
This is the function that I am using with the PSSIP conf that I send before:
NoOp(** PJSIP DEVICE STATE 2 = ${DEVICE_STATE(PJSIP/KAMnet_TST1)} );
This is what I get:
"
PJSIP DEVICE STATE = NOT_INUSE **"

I need to detect the status of the KAMnet_TST1 endpoint

thx

And what is the status of the endpoint? is it in use? Can you provide console output showing what it is doing and such?

Hello
Thank you for your quick answer

  1. Attached output form console for ENDPOINT status with command : pjsip show aors

[root@vm-tann-n-01 ~]# vvvr
Asterisk 13.2.0, Copyright © 1999 - 2014, Digium, Inc. and others.
Created by Mark Spencer markster@digium.com
Asterisk comes with ABSOLUTELY NO WARRANTY; type ‘core show warranty’ for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type ‘core show license’ for details.

Connected to Asterisk 13.2.0 currently running on vm-tann-n-01 (pid = 16351)
vm-tann-n-01*CLI> pjsip show aors

  Aor:  <Aor..............................................>  <MaxContact>
Contact:  <Aor/ContactUri.................................>  <Status....>  <RTT(ms)..>

=========================================================================================

  Aor:  KAMnet_TST1                                          0
Contact:  KAMnet_TST1/sip:10.25.153.150:5060;user=phone      Avail               2.314

vm-tann-n-01*CLI>

  1. Attached oupout form console for the DEVICE_STATE
    – Executing [s@Dialer_app:37] NoOp(“Local/s@Dialer_context_ael-00000000;2”, “** PJSIP DEVICE STATE = NOT_INUSE **”) in new stack

  2. Attached oupout from ael file:
    NoOp(** PJSIP DEVICE STATE = ${DEVICE_STATE(PJSIP/KAMnet_TST1)} **);

Do you need more info ?
Thx

I don’t see anything wrong with what you’ve provided. The endpoint is available.

Is it actually in use in Asterisk?

hello jcolp

sorry i didn’t understand 100% your question ,and how to check if it in use?
if i understod you good you will see a call was establish to the endpoint in the attached full outpout console

do you need more info?

Thx
Liad

[root@vm-tann-n-01 ~]# vvvr
Asterisk 13.2.0, Copyright © 1999 - 2014, Digium, Inc. and others.
Created by Mark Spencer markster@digium.com
Asterisk comes with ABSOLUTELY NO WARRANTY; type ‘core show warranty’ for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type ‘core show license’ for details.

Connected to Asterisk 13.2.0 currently running on vm-tann-n-01 (pid = 16351)
– Attempting call on local/s@Dialer_context_ael for application wait(0.1) (Retry 1)
– Called s@Dialer_context_ael
– Executing [s@Dialer_context_ael:1] NoOp(“Local/s@Dialer_context_ael-00000001;2”, “*** Dialer_service ael ") in new stack
– Executing [s@Dialer_context_ael:2] Goto(“Local/s@Dialer_context_ael-00000001;2”, “Dialer_app,s,begin”) in new stack
– Goto (Dialer_app,s,1)
– Executing [s@Dialer_app:1] NoOp(“Local/s@Dialer_context_ael-00000001;2”, "
* Dialer_service App****”) in new stack
– Executing [s@Dialer_app:2] Set(“Local/s@Dialer_context_ael-00000001;2”, “__trace=Dialer_start”) in new stack
– Executing [s@Dialer_app:3] Set(“Local/s@Dialer_context_ael-00000001;2”, “__Csrc=37163099”) in new stack
– Executing [s@Dialer_app:4] Set(“Local/s@Dialer_context_ael-00000001;2”, “__Cdest=039556744”) in new stack
– Executing [s@Dialer_app:5] Set(“Local/s@Dialer_context_ael-00000001;2”, “__Ctime=”) in new stack
– Executing [s@Dialer_app:6] Set(“Local/s@Dialer_context_ael-00000001;2”, “__FileName1=53_132.wav”) in new stack
– Executing [s@Dialer_app:7] Set(“Local/s@Dialer_context_ael-00000001;2”, “__FileName2=N”) in new stack
– Executing [s@Dialer_app:8] Set(“Local/s@Dialer_context_ael-00000001;2”, “CALLERID(num)=37163099”) in new stack
– Executing [s@Dialer_app:9] Set(“Local/s@Dialer_context_ael-00000001;2”, “__ringtime=80”) in new stack
– Executing [s@Dialer_app:10] Set(“Local/s@Dialer_context_ael-00000001;2”, “__DialPlanType=message”) in new stack
– Executing [s@Dialer_app:11] Set(“Local/s@Dialer_context_ael-00000001;2”, “__num_id=347”) in new stack
– Executing [s@Dialer_app:12] Set(“Local/s@Dialer_context_ael-00000001;2”, “__nextdestnum=NONE”) in new stack
– Executing [s@Dialer_app:13] Set(“Local/s@Dialer_context_ael-00000001;2”, “__CampainID=53”) in new stack
– Executing [s@Dialer_app:14] GotoIf(“Local/s@Dialer_context_ael-00000001;2”, “0?15:17”) in new stack
– Goto (Dialer_app,s,17)
– Executing [s@Dialer_app:17] Set(“Local/s@Dialer_context_ael-00000001;2”, “__DIVERSION=sip:37163099@10.25.131.119;privacy=full;screen=no;reason=unconditional”) in new stack
– Executing [s@Dialer_app:18] NoOp(“Local/s@Dialer_context_ael-00000001;2”, “Finish if_Dialer_app_143”) in new stack
– Executing [s@Dialer_app:19] Set(“Local/s@Dialer_context_ael-00000001;2”, “__CALL_START_TIME=20:01:23.251 GMT Sun Mar 06 2016”) in new stack
– Executing [s@Dialer_app:20] Set(“Local/s@Dialer_context_ael-00000001;2”, “__start_time=2016-03-06 20:01:23.252”) in new stack
– Executing [s@Dialer_app:21] Set(“Local/s@Dialer_context_ael-00000001;2”, “__start_t=20:01:23.252”) in new stack
– Executing [s@Dialer_app:22] GotoIf(“Local/s@Dialer_context_ael-00000001;2”, “1?23:33”) in new stack
– Goto (Dialer_app,s,23)
– Executing [s@Dialer_app:23] GotoIf(“Local/s@Dialer_context_ael-00000001;2”, “0?24:28”) in new stack
– Goto (Dialer_app,s,28)
– Executing [s@Dialer_app:28] NoOp(“Local/s@Dialer_context_ael-00000001;2”, “** random 2 ") in new stack
– Executing [s@Dialer_app:29] Set(“Local/s@Dialer_context_ael-00000001;2”, “__channelname=KAMnet_TST1”) in new stack
– Executing [s@Dialer_app:30] Set(“Local/s@Dialer_context_ael-00000001;2”, “__PAsserted=sip:37270000;ss7-cpc=10;cpc=ordinary@10.25.194.161;user=phone”) in new stack
– Executing [s@Dialer_app:31] NoOp(“Local/s@Dialer_context_ael-00000001;2”, “Finish if_if_Dialer_app_144_145”) in new stack
– Executing [s@Dialer_app:32] Goto(“Local/s@Dialer_context_ael-00000001;2”, “36”) in new stack
– Goto (Dialer_app,s,36)
– Executing [s@Dialer_app:36] NoOp(“Local/s@Dialer_context_ael-00000001;2”, “Finish if_Dialer_app_144”) in new stack
– Executing [s@Dialer_app:37] NoOp(“Local/s@Dialer_context_ael-00000001;2”, "
PJSIP DEVICE STATE = NOT_INUSE ") in new stack
– Executing [s@Dialer_app:38] NoOp(“Local/s@Dialer_context_ael-00000001;2”, "
PJSIP AOR = KAMnet_TST1@@sip:10.25.153.150:5060;user=phone ") in new stack
[Mar 6 20:01:23] ERROR[25738][C-00000001]: func_pjsip_contact.c:111 pjsip_contact_function_read: Cannot call PJSIP_CONTACT with an empty field name to query
– Executing [s@Dialer_app:39] NoOp(“Local/s@Dialer_context_ael-00000001;2”, "
PJSIP CONTACT = **”) in new stack
– Executing [s@Dialer_app:40] DumpChan(“Local/s@Dialer_context_ael-00000001;2”, “”) in new stack

Dumping Info For Channel: Local/s@Dialer_context_ael-00000001;2:

Info:
Name= Local/s@Dialer_context_ael-00000001;2
Type= Local
UniqueID= vm-tann-n-01.bgtehila.com-1457287283.4
LinkedID= vm-tann-n-01.bgtehila.com-1457287283.3
CallerIDNum= 37163099
CallerIDName= (N/A)
ConnectedLineIDNum= (N/A)
ConnectedLineIDName=(N/A)
DNIDDigits= (N/A)
RDNIS= (N/A)
Parkinglot=
Language= en
State= Ring (4)
Rings= 0
NativeFormat= (slin)
WriteFormat= slin
ReadFormat= slin
RawWriteFormat= slin
RawReadFormat= slin
WriteTranscode= No
ReadTranscode= No
1stFileDescriptor= -1
Framesin= 0
Framesout= 0
TimetoHangup= 0
ElapsedTime= 0h0m0s
BridgeID= (Not bridged)
Context= Dialer_app
Extension= s
Priority= 40
CallGroup=
PickupGroup=
Application= DumpChan
Data= (Empty)
Blocking_in= (Not Blocking)

Variables:
PAsserted=sip:37270000;ss7-cpc=10;cpc=ordinary@10.25.194.161;user=phone
channelname=KAMnet_TST1
start_t=20:01:23.252
start_time=2016-03-06 20:01:23.252
CALL_START_TIME=20:01:23.251 GMT Sun Mar 06 2016
DIVERSION=sip:37163099@10.25.131.119;privacy=full;screen=no;reason=unconditional
CampainID=53
nextdestnum=NONE
num_id=347
DialPlanType=message
ringtime=80
FileName2=N
FileName1=53_132.wav
Ctime=
Cdest=039556744
Csrc=37163099
trace=Dialer_start
call_id=347
filename2=N
filename1=53_132.wav
accountcode=Dialer
CallDest=039556744
CallSrc=37163099

-- Executing [s@Dialer_app:41] Dial("Local/s@Dialer_context_ael-00000001;2", "PJSIP/039556744@KAMnet_TST1,80,G(Dialer_answer,s,begin)b(Dialer_app,add_header,1)") in new stack
-- PJSIP/KAMnet_TST1-00000001 Internal Gosub(Dialer_app,add_header,1) start
-- Executing [add_header@Dialer_app:1] Set("PJSIP/KAMnet_TST1-00000001", "__CallId2=") in new stack
-- Executing [add_header@Dialer_app:2] GotoIf("PJSIP/KAMnet_TST1-00000001", "0?3:5") in new stack
-- Goto (Dialer_app,add_header,5)
-- Executing [add_header@Dialer_app:5] NoOp("PJSIP/KAMnet_TST1-00000001", "Finish if_Dialer_app_146") in new stack
-- Executing [add_header@Dialer_app:6] Return("PJSIP/KAMnet_TST1-00000001", "") in new stack

== Spawn extension (app-router, s, 1) exited non-zero on ‘PJSIP/KAMnet_TST1-00000001’
– PJSIP/KAMnet_TST1-00000001 Internal Gosub(Dialer_app,add_header,1) complete GOSUB_RETVAL=
– Called PJSIP/039556744@KAMnet_TST1
– PJSIP/KAMnet_TST1-00000001 is making progress passing it to Local/s@Dialer_context_ael-00000001;2
– Local/s@Dialer_context_ael-00000001;1 is making progress
vm-tann-n-01*CLI>
Disconnected from Asterisk server
Asterisk cleanly ending (0).
Executing last minute cleanups
You have new mail in /var/spool/mail/root
[root@vm-tann-n-01 ~]#

The state will go to in use if a channel is currently established to the specified endpoint. At the time you are calling DEVICE_STATE is this true? If not then it would show not in use.

In particular, I think what was being said is that Asterisk has no idea about the state of the actual device except for what it can deduce from its own state. If there is a connection to the device that is not from Asterisk, Asterisk will not count that towards an in-use state.

Hello jcolp , david

Thank you for your answers, and sorry for my late replay
1/ once I put the function DEVICE_STATE after the answer of the remote site the status was INUSE

2/ BUT the main issue is that I want to know what is the status of the PEER\EndPoint before the dial command

Why?

I am checking with option the endpoint KAMnet_TST1 with qualify_frequency parameter
When option is not replaying , KAMnet_TST1 is Unavail and I need to make dial to other EndPoint (attached console)

I need a function like : pjsip show aor KAMnet_TST1 that will return me the status Unavail or Avail

=========================================================================================
======================================= Attached Console when option is down==================

vm-tann-n-01*CLI> pjsip show aor KAMnet_TST1

  Aor:  <Aor..............................................>  <MaxContact>
Contact:  <Aor/ContactUri.................................>  <Status....>  <RTT(ms)..>

=========================================================================================

  Aor:  KAMnet_TST1                                          0
Contact:  KAMnet_TST1/sip:10.25.153.150:5060;user=phone      Unavail             0.000

ParameterName : ParameterValue

authenticate_qualify : false
contact : sip:10.25.153.150:5060;user=phone
default_expiration : 3600
mailboxes :
max_contacts : 0
maximum_expiration : 7200
minimum_expiration : 60
outbound_proxy :
qualify_frequency : 10
remove_existing : false
support_path : false

=========================================================================================
======================================= Attached Console when option is UP==================

vm-tann-n-01*CLI> pjsip show aor KAMnet_TST1

  Aor:  <Aor..............................................>  <MaxContact>
Contact:  <Aor/ContactUri.................................>  <Status....>  <RTT(ms)..>

=========================================================================================

  Aor:  KAMnet_TST1                                          0
Contact:  KAMnet_TST1/sip:10.25.153.150:5060;user=phone      Avail               2.344

ParameterName : ParameterValue

authenticate_qualify : false
contact : sip:10.25.153.150:5060;user=phone
default_expiration : 3600
mailboxes :
max_contacts : 0
maximum_expiration : 7200
minimum_expiration : 60
outbound_proxy :
qualify_frequency : 10
remove_existing : false
support_path : false

The device state of the endpoint will change when the endpoint becomes unreachable. Should go to unavailable if I remember right. Additionally you could also just Dial the endpoint like normal and check the DIALSTATUS. If it is CHANUNAVAIL then the endpoint wasn’t there to dial.