I am originating a channel through ARI. During it I have set a HANGUPCAUSE channel variable. After the channel timeout i got the channel destroyed event. But rather than showing the cause which I set, it is showing 0 Unknown. Can anyone help me with this.
You can’t set hangup cause like that. Did something tell you that you could? The hangup cause is set when the channel is hung up, be it through whatever means that occurs.
Additional explanation. HANGUPCAUSE and a few others, are really functions, even though you use the syntax for variables. It directly reflects the numerical value in a field in the channel data structure, rather than being the string value of a key-value pair.
While originating, I am getting “0 – Unknown” after a timeout, but for create and dial, I’m getting “16 – Normal Clearing.”
My question is, why am I getting “0 – Unknown” for the timeout case, and why is it different for both scenarios?
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
I am using an ARI application in which I create channels in two different ways:
-
Using Originate
-
Using Create + Dial
In both cases, I set a timeout.
Previously, for Create + Dial, when the timeout was reached, the hangup cause returned was 16 instead of 19 (No user responding / No answer). This issue has been fixed in the newer version.
However, for Originate channels, when the channel times out, I am still receiving a hangup cause code of 0 (Unknown).
My question is:
Should this scenario also return cause code 19 (No user responding / No answer) instead of 0?
I am attaching screenshots for both scenarios for reference.
Originate Case
Create And Dial Case
Okay, so you’re saying the Reason code placed in the CANCEL request isn’t 19. What about other events? Are those also incorrect?
Yes its incorrect for this scenario and correct for others.
I don’t understand that response. Are you saying that ONLY the Reason header has the wrong cause code, while the events relating to the channel have the CORRECT cause code?
I am referring specifically to an issue with the hangup reason code.
While debugging, I noticed that the reason code is being set after the channel is already hung up in the following code path:
ast_hangup(channel->owner);
channel->cause = AST_CAUSE_NO_ANSWER;
channel->owner = NULL;
This is in the handle_timeout_trip function in main/dial.c.
Because the cause is set after ast_hangup() is called, the hangup reason ends up being reported as 0 (Unknown). When I moved the cause assignment before calling ast_hangup(), the behavior worked as expected and the correct cause (AST_CAUSE_NO_ANSWER / 19) was propagated.
I am not sure whether this ordering is intentional or an oversight. Could you please clarify if this is purposely done, or if the cause should be set before hanging up the channel?
Hangup reason code is a broad thing. I asked my question to determine if it was isolated to the Reason header in the CANCEL request, or to the channel as a whole which would have scoped the area to look at.
I don’t know, that code is ancient which means the only place to maybe find out is looking at the git history which you have access to. It may or may not be mentioned, if it isn’t then it was probably an oversight and you could put up a PR for review (after following the instructions[1] for doing so).
I’ve always felt that the commit history should contain explanations about why things were changed (in the respective commit), as distinct from why they are the way they are at any point. The latter should go in comments or docs in the source.

