[asterisk-bugs] [JIRA] (ASTERISK-28451) PJSIP - HANGUPCAUSE(<channel>, tech) fails to get SIP cause for rejected calls

Gareth Blades (JIRA) noreply at issues.asterisk.org
Fri Jun 14 11:56:47 CDT 2019


Gareth Blades created ASTERISK-28451:
----------------------------------------

             Summary: PJSIP - HANGUPCAUSE(<channel>,tech) fails to get SIP cause for rejected calls
                 Key: ASTERISK-28451
                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-28451
             Project: Asterisk
          Issue Type: Bug
      Security Level: None
          Components: Channels/chan_pjsip
    Affects Versions: 13.21.0
         Environment: CentOS 7
            Reporter: Gareth Blades
            Severity: Minor


Using Asterisk certified/13.21-cert2.

When a destination SIP server rejects a call, a hangup handler running in the outbound PJSIP channel can't get the SIP status message from HANGUPCAUSE(<channel>,tech), and HANGUPCAUSE_KEYS() returns nothing.

The same hangup handler works perfectly on Asterisk 11 using the older SIP engine.

This can be demonstrated with this test dialplan:

{code}
[testdial]
exten => _X.,1,Dial(PJSIP/custom/sip:901 at pbx.example.com,,b(testaddhandler^set_handler^1))
same => n,Hangup()

[testaddhandler]
exten => set_handler,1,NoOp(Setting handler)
same => n,Set(CHANNEL(hangup_handler_push)=testhandler,outbound_handler,1)
same => n,Return()

[testhandler]
exten => outbound_handler,1,NoOp(## Hangup handler)
same => n,NoOp(## CHANNEL=${CHANNEL})
same => n,NoOp(## HANGUPCAUSE_KEYS=${HANGUPCAUSE_KEYS()})
same => n,NoOp(## HANGUPCAUSE=${HANGUPCAUSE(${CHANNEL},tech)})
same => n,Return()
{code}


I have outlined 4 scenarios here. The first 3 work fine, but the last one breaks.


*Scenario 1* - the destination (sip:901 at pbx.example.com in this example) starts ringing (and sends SIP 180 back) but then the caller hangs up before it's answered. The hangup handler can get the sip status in this scenario; from the Asterisk console:
{code}
    -- Executing [outbound_handler at testhandler:1] NoOp("PJSIP/custom-000000ec", "## Hangup handler") in new stack
    -- Executing [outbound_handler at testhandler:2] NoOp("PJSIP/custom-000000ec", "## CHANNEL=PJSIP/custom-000000ec") in new stack
    -- Executing [outbound_handler at testhandler:3] NoOp("PJSIP/custom-000000ec", "## HANGUPCAUSE_KEYS=PJSIP/custom-000000ec") in new stack
    -- Executing [outbound_handler at testhandler:4] NoOp("PJSIP/custom-000000ec", "## HANGUPCAUSE=SIP 180 Ringing") in new stack
{code}

*Scenario 2* - the destination (sip:901 at pbx.example.com in this example) is answered and then the caller hangs up. This is also OK:
{code}
    -- Executing [outbound_handler at testhandler:1] NoOp("PJSIP/custom-000000ee", "## Hangup handler") in new stack
    -- Executing [outbound_handler at testhandler:2] NoOp("PJSIP/custom-000000ee", "## CHANNEL=PJSIP/custom-000000ee") in new stack
    -- Executing [outbound_handler at testhandler:3] NoOp("PJSIP/custom-000000ee", "## HANGUPCAUSE_KEYS=PJSIP/squiresvi-000000ed,PJSIP/custom-000000ee") in new stack
    -- Executing [outbound_handler at testhandler:4] NoOp("PJSIP/custom-000000ee", "## HANGUPCAUSE=SIP 200 OK") in new stack
{code}

*Scenario 3* - the destination (sip:901 at pbx.example.com in this example) is answered and then the *callee* hangs up. This is OK as well:
{code}
    -- Executing [outbound_handler at testhandler:2] NoOp("PJSIP/custom-000000f0", "## CHANNEL=PJSIP/custom-000000f0") in new stack
  == Spawn extension (testdial, 01476292507, 1) exited non-zero on 'PJSIP/squiresvi-000000ef'
    -- Executing [outbound_handler at testhandler:3] NoOp("PJSIP/custom-000000f0", "## HANGUPCAUSE_KEYS=PJSIP/custom-000000f0,PJSIP/squiresvi-000000ef") in new stack
    -- Executing [outbound_handler at testhandler:4] NoOp("PJSIP/custom-000000f0", "## HANGUPCAUSE=SIP 200 OK") in new stack
{code}


*Scenario 4* - a call is made to a non-existant SIP address on the destination server (901xxxx at sip.example.com in my attached example) so the remote server sends back SIP 404. *THIS BREAKS*
{code}
    -- Executing [outbound_handler at testhandler:1] NoOp("PJSIP/custom-000000f2", "## Hangup handler") in new stack
    -- Executing [outbound_handler at testhandler:2] NoOp("PJSIP/custom-000000f2", "## CHANNEL=PJSIP/custom-000000f2") in new stack
    -- Executing [outbound_handler at testhandler:3] NoOp("PJSIP/custom-000000f2", "## HANGUPCAUSE_KEYS=") in new stack
[Jun 13 19:47:15] WARNING[19118][C-00000096]: func_hangupcause.c:140 hangupcause_read: Unable to find information for channel PJSIP/custom-000000f2
    -- Executing [outbound_handler at testhandler:4] NoOp("PJSIP/custom-000000f2", "## HANGUPCAUSE=") in new stack
{code}

Note that in my testing, this doesn't just break on SIP 404 responses, but any remote server rejection.




--
This message was sent by Atlassian JIRA
(v6.2#6252)



More information about the asterisk-bugs mailing list