[asterisk-bugs] [JIRA] (ASTERISK-30476) Hangup Cause is not passed in ChannelHanguprequest

Karl Gaize (JIRA) noreply at issues.asterisk.org
Wed Mar 22 08:43:03 CDT 2023


    [ https://issues.asterisk.org/jira/browse/ASTERISK-30476?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=261630#comment-261630 ] 

Karl Gaize commented on ASTERISK-30476:
---------------------------------------

so, I guess what we're talking about here is the difference between a back-to-back system and not. we're using the "internal" asterisk as a back-to-back agent that generates calls that stay completely inside our network, and the "border" asterisks take care of routing outbound and inbound calls based on routing code prefixes and dialplan.

when "fixing" this problem, I implemented the chan_pjsip_session_end() function with a slightly deeper logic tree, which allowed me to see which hangup causes were being used is as follows:

	// if the channel has a hangup cause
	if (ast_channel_hangupcause(session->channel)) {
		// if the session has a cause as well
		if(session->inv_session && session->inv_session->cause) {
			// use that
			ast_debug(1, "chan_pjsip_session_end on channel %s session cause overrides channel cause", ast_channel_name(session->channel));
			int cause = hangup_sip2cause(session->inv_session->cause);
			ast_queue_hangup_with_cause(session->channel, cause);
		}
		else {
			// else use the channel cause
			ast_debug(1, "chan_pjsip_session_end on channel %s session cause empty, using channel cause", ast_channel_name(session->channel));
			int cause = hangup_sip2cause(ast_channel_hangupcause(session->channel));
			ast_queue_hangup_with_cause(session->channel, cause);
		}
	// else if we have a session
	} else if  (session->inv_session) {
		// use the sessions's cause and pass it through
		ast_debug(1, "chan_pjsip_session_end on channel %s channel cause empty, using session cause", ast_channel_name(session->channel));
		int cause = hangup_sip2cause(session->inv_session->cause);
		ast_queue_hangup_with_cause(session->channel, cause);
	} else {
		// otherwise, we have no cause
		ast_debug(1, "chan_pjsip_session_end on channel %s channel cause empty, session cause empty", ast_channel_name(session->channel));
		ast_queue_hangup(session->channel);
	}

and this works for all cases we've been able to throw at it so far. This change should probably fall foul of the "change in behaviour" that you mentioned as we're definitively updating the hangup cause, but as I'm still using ast_queue_hangup_with_cause I'm not so sure. 

> Hangup Cause is not passed in ChannelHanguprequest
> --------------------------------------------------
>
>                 Key: ASTERISK-30476
>                 URL: https://issues.asterisk.org/jira/browse/ASTERISK-30476
>             Project: Asterisk
>          Issue Type: Bug
>      Security Level: None
>          Components: Channels/chan_pjsip
>    Affects Versions: 18.11.2
>         Environment: debian / centos 7
>            Reporter: Karl Gaize
>            Assignee: Karl Gaize
>
> We are using Asterisk in two ways, as an internal call management API, and as an external facing routing mechansim. We initiate an outbound call using ARI (on the internal asterisk) which prefixes the dialled number with some routing codes and calls the "border" asterisk. the "border" asterisk then interprets the routing codes and places a new call on the correct outbound trunk, then connects up the call from the "internal" asterisk to the new outbound call.
> When one of these calls is hung up, or rejected, the "border" asterisk correctly gets the hangup cause, and sends it via SIP packets to the "internal" asterisk along with the hangup.
> When the "internal" asterisk receives the hangup request, it should generate a "channelHangupRequest" event to the ARI application controlling the call, however, the "cause" value is omitted from this event.
> Inspecting the "chan_pjsip_session_end" function in chan_pjsip, we find that the hangup cause is only to be added to the outgoing event, if the "ast_channel_hangupcause" returns zero.
> in all cases where a valid cause was returned from the "border" asterisk, the hangup cause was communicated from the border to the internal asterisk, "ast_channel_hangupcause" returned NON-ZERO, and the cause was NOT added to the event data.
> we could see no other option than to modify "chan_pjsip_session_end" to allow it to put the cause value in the event data, if cause data was found.
> modified code to handle this scenario can be produced if required, but what we're really after is a definitive declaration of whether this functionality is considered to be a bug, or by design.



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



More information about the asterisk-bugs mailing list