# DEVICE\_STATE output is NOT\_INUSE with PJSIP conf

**URL:** <https://community.asterisk.org/t/device-state-output-is-not-inuse-with-pjsip-conf/65883>\
**Category:** Uncategorized\
**Created:** [March 6, 2016, 12:27pm UTC](https://community.asterisk.org/t/device-state-output-is-not-inuse-with-pjsip-conf/65883 "2016-03-06T12:27:08Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![liadbidani](https://avatars.discourse-cdn.com/v4/letter/l/e5b9ba/32.png) [@liadbidani](https://community.asterisk.org/u/liadbidani)\
**Post date:** [March 6, 2016, 12:27pm UTC](https://community.asterisk.org/t/device-state-output-is-not-inuse-with-pjsip-conf/65883/1 "2016-03-06T12:27:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![jcolp](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/jcolp/32/8848_2.png) [@jcolp](https://community.asterisk.org/u/jcolp)\
**Post date:** [March 6, 2016, 2:33pm UTC](https://community.asterisk.org/t/device-state-output-is-not-inuse-with-pjsip-conf/65883/2 "2016-03-06T14:33:27Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![liadbidani](https://avatars.discourse-cdn.com/v4/letter/l/e5b9ba/32.png) [@liadbidani](https://community.asterisk.org/u/liadbidani)\
**Post date:** [March 6, 2016, 3:03pm UTC](https://community.asterisk.org/t/device-state-output-is-not-inuse-with-pjsip-conf/65883/3 "2016-03-06T15:03:58Z")

</div>

> [@jcolp](#):
>
> it’s always enabled

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

---

<div class="post-metadata">

**Author:** ![jcolp](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/jcolp/32/8848_2.png) [@jcolp](https://community.asterisk.org/u/jcolp)\
**Post date:** [March 6, 2016, 3:15pm UTC](https://community.asterisk.org/t/device-state-output-is-not-inuse-with-pjsip-conf/65883/4 "2016-03-06T15:15:16Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![liadbidani](https://avatars.discourse-cdn.com/v4/letter/l/e5b9ba/32.png) [@liadbidani](https://community.asterisk.org/u/liadbidani)\
**Post date:** [March 6, 2016, 3:30pm UTC](https://community.asterisk.org/t/device-state-output-is-not-inuse-with-pjsip-conf/65883/5 "2016-03-06T15:30:55Z")

</div>

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](mailto: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

---

<div class="post-metadata">

**Author:** ![jcolp](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/jcolp/32/8848_2.png) [@jcolp](https://community.asterisk.org/u/jcolp)\
**Post date:** [March 6, 2016, 3:42pm UTC](https://community.asterisk.org/t/device-state-output-is-not-inuse-with-pjsip-conf/65883/6 "2016-03-06T15:42:35Z")

</div>

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

Is it actually in use in Asterisk?

---

<div class="post-metadata">

**Author:** ![liadbidani](https://avatars.discourse-cdn.com/v4/letter/l/e5b9ba/32.png) [@liadbidani](https://community.asterisk.org/u/liadbidani)\
**Post date:** [March 6, 2016, 6:24pm UTC](https://community.asterisk.org/t/device-state-output-is-not-inuse-with-pjsip-conf/65883/7 "2016-03-06T18:24:35Z")

</div>

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](mailto: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 ~]#

---

<div class="post-metadata">

**Author:** ![jcolp](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/jcolp/32/8848_2.png) [@jcolp](https://community.asterisk.org/u/jcolp)\
**Post date:** [March 6, 2016, 6:26pm UTC](https://community.asterisk.org/t/device-state-output-is-not-inuse-with-pjsip-conf/65883/8 "2016-03-06T18:26:43Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![david551](https://avatars.discourse-cdn.com/v4/letter/d/3bc359/32.png) [@david551](https://community.asterisk.org/u/david551)\
**Post date:** [March 7, 2016, 9:00am UTC](https://community.asterisk.org/t/device-state-output-is-not-inuse-with-pjsip-conf/65883/9 "2016-03-07T09:00:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![liadbidani](https://avatars.discourse-cdn.com/v4/letter/l/e5b9ba/32.png) [@liadbidani](https://community.asterisk.org/u/liadbidani)\
**Post date:** [March 8, 2016, 10:34am UTC](https://community.asterisk.org/t/device-state-output-is-not-inuse-with-pjsip-conf/65883/10 "2016-03-08T10:34:22Z")

</div>

> [@liadbidani](#):
>
> qualify\_frequency

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

---

<div class="post-metadata">

**Author:** ![jcolp](https://sea1.discourse-cdn.com/asterisk/user_avatar/community.asterisk.org/jcolp/32/8848_2.png) [@jcolp](https://community.asterisk.org/u/jcolp)\
**Post date:** [March 8, 2016, 11:39am UTC](https://community.asterisk.org/t/device-state-output-is-not-inuse-with-pjsip-conf/65883/11 "2016-03-08T11:39:40Z")

</div>

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.
