Summary:ASTERISK-17735: Hangup function not sending correct SIP cause code
Reporter:Vlasis Hatzistavrou (vhatz)Labels:
Date Opened:2011-04-21 10:12:37Date Closed:2011-07-26 14:46:14
Versions:1.4.40 Frequency of
Environment:Attachments:( 0) myDebugLog
Test scenario is this:

SIP Client --INVITE-> Asterisk --INVITE-> SIP Peer01

Dialplan is:

exten => _X.,1,Dial(SIP/12345@sippeer01,,,)

exten => i,1,Hangup()
exten => t,1,Hangup()
exten => h,1,Hangup()


exten => _X.,1,Dial(SIP/12345@sippeer01,,,)

exten => i,1,Hangup()
exten => t,1,Hangup()
exten => h,1,Hangup(17) (or any cause number as an argument to the hangup function).


exten => _X.,1,Dial(SIP/12345@sippeer01,,,)

exten => i,1,Hangup(${HANGUPCAUSE})
exten => t,1,Hangup(${HANGUPCAUSE})
exten => h,1,Hangup(${HANGUPCAUSE})

If the call is not accepted by sippeer01 for any reason (for example, SIP cause 404, or 486, etc), this message is returned to Asterisk, which in turn changes the SIP cause to 503 for all cases, even when we try to override the cause by setting an argument manually in Hangup() in [test2] and [test3].

SIP Client <-503-- Asterisk <-404-- SIP Peer01

It seems that the Hangup() function does not work as expected and has no impact on the SIP cause code that is sent to the calling SIP Client, although the packet which contains the 503 reply, also contains the headers:

X-Asterisk-HangupCause: Unallocated (unassigned) number
X-Asterisk-HangupCauseCode: 1

which show the correct response from the remote end (404).

I believe this is a bug, as Hangup() would function as expected in previous Asterisk versions.
Comments:By: Paul Belanger (pabelanger) 2011-04-25 21:13:18

We require a complete debug log to help triage the issue.

This document will provide instructions on how to collect debugging logs from an Asterisk machine for the purpose of helping bug marshals troubleshoot an issue:


By: Vlasis Hatzistavrou (vhatz) 2011-04-26 08:47:57

I have attached the requested debug log.

By: Paul Belanger (pabelanger) 2011-04-26 11:35:02

What happens if you move the Hangup(17) outside the h exten?  Create a gotoif for CONGESTION, then Hangup(17).

By: Vlasis Hatzistavrou (vhatz) 2011-04-26 11:50:52

I haven't tried what you suggest, I will test it shortly.

However, if what you propose works, the issue of why the function does not work in the h extension still remains, when in previous Asterisk versions it used to work fine.

By: Paul Belanger (pabelanger) 2011-04-26 11:53:47

If it worked previously and not now, then yes it would be a regression.  If you can post a debug log from a working version, it might be helpful.

By: Vlasis Hatzistavrou (vhatz) 2011-04-28 09:45:18

It's been a long time since I checked for this behavior in older versions, so I can't remember at this moment. I will install a few older versions (perhaps 1.2.x) and I'll post the results here, as soon as possible.

By: Leif Madsen (lmadsen) 2011-05-10 16:20:44


By: Vlasis Hatzistavrou (vhatz) 2011-05-10 17:54:34

Sorry for not getting back with more feedback, there was heavy workload during the past weeks.

To clarify, I can verify that with current Asterisk versions, the function Hangup(<cause>) sends the appropriate <cause> if it is outside the h extension. If the Hangup(<cause>) is in the h extension then does not send the <cause> to the calling party but instead sends only 503 irrespective of the reason why the remote end hang up.

Unfortunately, it has been a very long time since I last saw


behave as expected, so I can't remember which version was working properly.

I am currently testing various 1.2 versions (and some early 1.4) as time permits to pinpoint the version which showed the desired behavior. Hopefully I will have something soon.

By: Russell Bryant (russell) 2011-07-26 14:46:08.703-0500

Per the Asterisk maintenance timeline page at http://www.asterisk.org/asterisk-versions maintenance (bug) support for the 1.4 and 1.6.x branches has ended. For continued maintenance support please move to the 1.8 branch which is a long term support (LTS) branch. For more information about branch support, please see https://wiki.asterisk.org/wiki/display/AST/Asterisk+Versions

If this is still an issue, please open a new issue so it can be re-triaged appropriately. Thanks!