Sip state “busy” after app-dnd-on context

Dear all. I have switched to FreePBX 17 with Asterisk 21.4.1
(I originally posted this question at asterisk forum, but got redirected here.)

I am trying to get our SNOM phones to get notified about other extensions being in dnd.
As the standard dialplan [app-dnd-on] sets the device state to “BUSY”, I am trying to catch the corresponding sip presence notification. “core show hint” correctly returns “busy”.

In comparison, actually being in a call, the hint shows “InUse”.

However, the sip messages are identical for busy and InUse.

Here is from an actual call, state:InUse:

Received from Udp:192.168.20.16:5060 on Udp:192.168.130.201:5060 at Aug 15 19:27:00.246 (1077 bytes):

NOTIFY sip:[email protected]:5060;line=va5dklpj SIP/2.0
Via: SIP/2.0/UDP 192.168.20.16:5060;rport;branch=z9hG4bKPj3876f15a-88c4-4174-8091-53c75319a47a
From: <sip:[email protected]>;tag=778e2e5b-2e97-4f07-bd6d-4a509de9bf4b
To: <sip:[email protected]>;tag=aaw9twr0jt
Contact: <sip:192.168.20.16:5060>
Call-ID: 313732333734303433353434303435-8uzc9koqu63w
CSeq: 5986 NOTIFY
Event: presence
Subscription-State: active;expires=3240
Allow-Events: presence, dialog, message-summary, refer
Max-Forwards: 70
User-Agent: FPBX-17.0.19.1(21.4.1)
Content-Type: application/pidf+xml
Content-Length: 472

<?xml version="1.0" encoding="UTF-8"?> <presence entity="sip:[email protected]" xmlns="urn:ietf:params:xml:ns:pidf" xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model" xmlns:rpid="urn:ietf:params:xml:ns:pidf:rpid"> <note>On the phone</note> <tuple id="12"> <status> <basic>open</basic> </status> <contact priority="1">sip:[email protected]</contact> </tuple> <dm:person> <rpid:activities> <rpid:on-the-phone /> </rpid:activities> </dm:person> </presence>

And the one for DND, state:busy I received 2! messages like the one below

Received from Udp:192.168.20.16:5060 on Udp:192.168.130.201:5060 at Aug 15 19:28:57.563 (1077 bytes):

NOTIFY sip:[email protected]:5060;line=va5dklpj SIP/2.0
Via: SIP/2.0/UDP 192.168.20.16:5060;rport;branch=z9hG4bKPj4e67f1b8-ef9b-4265-b70e-178c04fcf6d6
From: <sip:[email protected]>;tag=778e2e5b-2e97-4f07-bd6d-4a509de9bf4b
To: <sip:[email protected]>;tag=aaw9twr0jt
Contact: <sip:192.168.20.16:5060>
Call-ID: 313732333734303433353434303435-8uzc9koqu63w
CSeq: 5989 NOTIFY
Event: presence
Subscription-State: active;expires=3123
Allow-Events: presence, dialog, message-summary, refer
Max-Forwards: 70
User-Agent: FPBX-17.0.19.1(21.4.1)
Content-Type: application/pidf+xml
Content-Length: 472

<?xml version="1.0" encoding="UTF-8"?> <presence entity="sip:[email protected]" xmlns="urn:ietf:params:xml:ns:pidf" xmlns:dm="urn:ietf:params:xml:ns:pidf:data-model" xmlns:rpid="urn:ietf:params:xml:ns:pidf:rpid"> <note>On the phone</note> <tuple id="12"> <status> <basic>open</basic> </status> <contact priority="1">sip:[email protected]</contact> </tuple> <dm:person> <rpid:activities> <rpid:on-the-phone /> </rpid:activities> </dm:person> </presence>

To find out more, I changed the dialplan [app-dnd-on] to use state “ONHOLD”.
That made the phone receive one message with on hold, which would be correct. Sadly a few seconds later, the phone receives another message with on-the-phone and with that overrides the correct state.

Here is the corresponding part of the log:

-- Executing [*78@from-internal:5] Set("PJSIP/12-00000212", "STATE=ONHOLD") in new stack
    -- Executing [*78@from-internal:6] Gosub("PJSIP/12-00000212", "app-dnd-on,sstate,1()") in new stack
    -- Executing [sstate@app-dnd-on:1] Set("PJSIP/12-00000212", "DEVICE_STATE(Custom:DND12)=ONHOLD") in new stack
    -- Executing [sstate@app-dnd-on:2] Set("PJSIP/12-00000212", "DEVICES=12") in new stack
    -- Executing [sstate@app-dnd-on:3] GotoIf("PJSIP/12-00000212", "0?return") in new stack
    -- Executing [sstate@app-dnd-on:4] Set("PJSIP/12-00000212", "LOOPCNT=1") in new stack
    -- Executing [sstate@app-dnd-on:5] Set("PJSIP/12-00000212", "ITER=1") in new stack
    -- Executing [sstate@app-dnd-on:6] Set("PJSIP/12-00000212", "DEVICE_STATE(Custom:DEVDND12)=ONHOLD") in new stack
    -- Executing [sstate@app-dnd-on:7] Set("PJSIP/12-00000212", "ITER=2") in new stack
    -- Executing [sstate@app-dnd-on:8] GotoIf("PJSIP/12-00000212", "0?begin") in new stack
    -- Executing [sstate@app-dnd-on:9] Return("PJSIP/12-00000212", "") in new stack
    -- Executing [*78@from-internal:7] Playback("PJSIP/12-00000212", "do-not-disturb&activated") in new stack
    -- <PJSIP/12-00000212> Playing 'do-not-disturb.ulaw' (language 'de_DE')
    -- <PJSIP/12-00000212> Playing 'activated.ulaw' (language 'de_DE')
    -- Executing [*78@from-internal:8] Gosub("PJSIP/12-00000212", "macro-hangupcall,s,1()") in new stack
    -- Executing [s@macro-hangupcall:1] Set("PJSIP/12-00000212", "__MCVMSTATUS=") in new stack
    -- Executing [s@macro-hangupcall:2] Gosub("PJSIP/12-00000212", "app-missedcall-hangup,s,1()") in new stack
    -- Executing [s@app-missedcall-hangup:1] NoOp("PJSIP/12-00000212", "Dialed: s") in new stack
    -- Executing [s@app-missedcall-hangup:2] NoOp("PJSIP/12-00000212", "Caller: 12") in new stack
    -- Executing [s@app-missedcall-hangup:3] GotoIf("PJSIP/12-00000212", "0?exit") in new stack
    -- Executing [s@app-missedcall-hangup:4] Set("PJSIP/12-00000212", "EXTENNUM=s") in new stack
    -- Executing [s@app-missedcall-hangup:5] Set("PJSIP/12-00000212", "FEXTENNUM=s") in new stack
    -- Executing [s@app-missedcall-hangup:6] GotoIf("PJSIP/12-00000212", "0?exit") in new stack
    -- Executing [s@app-missedcall-hangup:7] AGI("PJSIP/12-00000212", "missedcallnotify.php,s,,s,0,,PJSIP/12-00000212,,,,") in new stack
    -- Launched AGI Script /var/lib/asterisk/agi-bin/missedcallnotify.php
    -- <PJSIP/12-00000212>AGI Script missedcallnotify.php completed, returning 0
    -- Executing [s@app-missedcall-hangup:8] Return("PJSIP/12-00000212", "") in new stack
    -- Executing [s@macro-hangupcall:3] GotoIf("PJSIP/12-00000212", "1?theend") in new stack
    -- Goto (macro-hangupcall,s,5)
    -- Executing [s@macro-hangupcall:5] ExecIf("PJSIP/12-00000212", "0?Set(CDR(recordingfile)=)") in new stack
    -- Executing [s@macro-hangupcall:6] Hangup("PJSIP/12-00000212", "") in new stack
  == Spawn extension (macro-hangupcall, s, 6) exited non-zero on 'PJSIP/12-00000212'
freepbx*CLI> core show hint 12
12@ext-local                  : PJSIP/12&Custom:DND12,CustomPresence:12                       State:Hold            Presence:available       Watchers  3
1234@default                  : SIP/1234                                                      State:Unavailable     Presence:not_set         Watchers  0
2 hints matching extension 12
freepbx*CLI> core show hint 12
12@ext-local                  : PJSIP/12&Custom:DND12,CustomPresence:12                       State:Busy            Presence:available       Watchers  3
1234@default                  : SIP/1234                                                      State:Unavailable     Presence:not_set         Watchers  0

As you can see, there is no action on the asterisk side, but the state changes from “hold” to “busy”.

Any help would be very welcome.

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