[Home]

Summary:ASTERISK-28428: app_dial: Incorrectly alters Hangup and DialEnd events when the c argument is passed, but app_dial didn't cancel the call.
Reporter:Jonas Swiatek (jonasswiatek)Labels:pjsip
Date Opened:2019-05-24 07:20:17Date Closed:
Priority:TrivialRegression?No
Status:Open/NewComponents:Applications/app_dial
Versions:16.3.0 Frequency of
Occurrence
Constant
Related
Issues:
Environment:Amazon Linux 2 (CentOS based)Attachments:
Description:Specific to chan_pjsip, chan_sip doesn't have this behavior.

I'll provide a few examples I've encountered where the AMI Events are incorrectly having their hangup cause set to 26. Answered Elsewhere.

The INVITE generated by app_dial wasn't canceled in any of the examples. Presumably app_dial would only cancel the call if timeout is reached, or if someone else answers the call. In all examples provided here, the initial invite is rejected by either 404 Not Found, 480 Temp. Unavailable or 486 Busy Here.

Following dial plan code example. Bug only presents itself when the c argument is used.
Registrar is a Kamailio server handling registration.

{code}
[dial]
exten => _.,1,DIAL(PJSIP/jonas2@registrar, 30, c)
same => n,Hangup()
{code}

*404 Not Found*

If user *jonas2* isn't registered and kamailio responds with *SIP 404 Not Found*, the AMI hangup event is expected to have Cause *1. Unallocated (unassigned) number*, however when the c argument is provided, the event looks as follows:

{code}
{
 "Event": "Hangup",
 "Channel": "PJSIP/registrar-000000dd",
 "ChannelState": 0,
 "ChannelStateDesc": "Down",
 "CallerIDNum": "jonas2",
 "CallerIDName": "<unknown>",
 "ConnectedLineNum": "jonas1",
 "ConnectedLineName": "jonas1",
 "AccountCode": "",
 "Context": "dial",
 "Exten": "jonas2",
 "Priority": "1",
 "Cause": 26,
 "Causetxt": "Answered elsewhere",
 "Linkedid": "ast007-1558613595.414",
 "Uniqueid": "ast007-1558613595.415",
 "UtcDate": "2019-05-23T12:13:15Z",
 "DateReceived": "23-05-2019 12:13:15",
 "Language": "en",
 "Privilege": "call,all",
 "SystemName": "ast007",
 "KafkaPartitionId": 0,
 "KafkaOffset": 0,
 "_sequence": 1839,
 "AdditionalAttributes": {
   "Cause-txt": "Answered elsewhere",
   "ApproxTimeStamp": "2019-05-23T12:13:16.628+00:00"
 }
}
{code}

The issue lies with the Cause and Causetxt fields, which should read 1/Unallocated (unassigned) number, since this call was NOT answered elsewhere, and app_dial didn't cancel the call. If the c argument isn't set, then this event correctly reads 1/Unallocated (unassigned) number.

*480 Temporarily Unavailable*

This status code is typically returned by SIP Phones if they're set in DND mode. It's returned without first sending a 180 Ringing provisional response. When the c argument is passed to app_dial, the event looks as follows:

{code}
{
 "Event": "Hangup",
 "Channel": "PJSIP/registrar-000000e3",
 "ChannelState": 0,
 "ChannelStateDesc": "Down",
 "CallerIDNum": "jonas2",
 "CallerIDName": "<unknown>",
 "ConnectedLineNum": "jonas1",
 "ConnectedLineName": "jonas1",
 "AccountCode": "",
 "Context": "dial",
 "Exten": "jonas2",
 "Priority": "1",
 "Cause": 26,
 "Causetxt": "Answered elsewhere",
 "Linkedid": "ast007-1558613775.420",
 "Uniqueid": "ast007-1558613775.421",
 "UtcDate": "2019-05-23T12:16:15Z",
 "DateReceived": "23-05-2019 12:16:15",
 "Language": "en",
 "Privilege": "call,all",
 "SystemName": "ast007",
 "KafkaPartitionId": 0,
 "KafkaOffset": 0,
 "_sequence": 1863,
 "AdditionalAttributes": {
   "Cause-txt": "Answered elsewhere",
   "ApproxTimeStamp": "2019-05-23T12:16:16.625+00:00"
 }
}
{code}

Again here, the Cause and Causetxt incorrectly reads 26/Answered Elsewhere, which is not true. This call was not answered, it was rejected and should read 19/User alerting, no answer. If the c argument isn't set, then this event correctly reads cause 19.

*486 Busy Here*

Same story as the previous two cases, with the addition that the DialEnd events are also getting inadvertently altered. When the c argument is set, the DialEnd event looks as follows:

{code}
{
 "Event": "DialEnd",
 "Channel": "PJSIP/registrar-000000e8",
 "ChannelState": 4,
 "ChannelStateDesc": "Ring",
 "CallerIDNum": "jonas1",
 "CallerIDName": "jonas1",
 "ConnectedLineNum": "jonas2",
 "ConnectedLineName": "<unknown>",
 "AccountCode": "",
 "Context": "dial",
 "Exten": "jonas2",
 "Priority": "2",
 "DestChannel": "PJSIP/registrar-000000e9",
 "DestChannelState": 5,
 "DestChannelStateDesc": "Ringing",
 "DestCallerIDNum": "jonas2",
 "DestCallerIDName": "<unknown>",
 "DestConnectedLineNum": "jonas1",
 "DestConnectedLineName": "jonas1",
 "DestAccountCode": "",
 "DestContext": "dial",
 "DestExten": "jonas2",
 "DestPriority": "1",
 "DestUniqueid": "ast007-1558613944.427",
 "DialStatus": "NOANSWER",
 "Forward": null,
 "Linkedid": "ast007-1558613944.426",
 "DestLinkedid": "ast007-1558613944.426",
 "Uniqueid": "ast007-1558613944.426",
 "UtcDate": "2019-05-23T12:19:06Z",
 "DateReceived": "23-05-2019 12:19:06",
 "Language": "en",
 "Privilege": "call,all",
 "SystemName": "ast007",
 "KafkaPartitionId": 0,
 "KafkaOffset": 0,
 "_sequence": 1889,
 "AdditionalAttributes": {
   "DestLanguage": "en",
   "ApproxTimeStamp": "2019-05-23T12:19:07.609+00:00"
 }
}
{code}

The DialStatus field should read "BUSY" in this case, which it also does if the c argument isn't passed.

For good measure, this is how the Hangup event looks:

{code}
{
 "Event": "Hangup",
 "Channel": "PJSIP/registrar-000000e9",
 "ChannelState": 5,
 "ChannelStateDesc": "Ringing",
 "CallerIDNum": "jonas2",
 "CallerIDName": "<unknown>",
 "ConnectedLineNum": "jonas1",
 "ConnectedLineName": "jonas1",
 "AccountCode": "",
 "Context": "dial",
 "Exten": "jonas2",
 "Priority": "1",
 "Cause": 26,
 "Causetxt": "Answered elsewhere",
 "Linkedid": "ast007-1558613944.426",
 "Uniqueid": "ast007-1558613944.427",
 "UtcDate": "2019-05-23T12:19:06Z",
 "DateReceived": "23-05-2019 12:19:06",
 "Language": "en",
 "Privilege": "call,all",
 "SystemName": "ast007",
 "KafkaPartitionId": 0,
 "KafkaOffset": 0,
 "_sequence": 1890,
 "AdditionalAttributes": {
   "Cause-txt": "Answered elsewhere",
   "ApproxTimeStamp": "2019-05-23T12:19:07.609+00:00"
 }
}
{code}

It also reads 26/Answered elsewhere, which should I believe should be 17/User busy, which it indeed is if the c argument isn't passed to app_dial

*Why is this a problem?*
Because the Hangup and DialEnd events become completely identical, it becomes impossible, or at least extremely difficult and unreliable to distingush between if a call was indeed Answered Elsewhere, the user wasn't registered, rejected the call or was DND, when the c argument is passed to app_dial.

Comments:By: Asterisk Team (asteriskteam) 2019-05-24 07:20:18.928-0500

Thanks for creating a report! The issue has entered the triage process. That means the issue will wait in this status until a Bug Marshal has an opportunity to review the issue. Once the issue has been reviewed you will receive comments regarding the next steps towards resolution.

A good first step is for you to review the [Asterisk Issue Guidelines|https://wiki.asterisk.org/wiki/display/AST/Asterisk+Issue+Guidelines] if you haven't already. The guidelines detail what is expected from an Asterisk issue report.

Then, if you are submitting a patch, please review the [Patch Contribution Process|https://wiki.asterisk.org/wiki/display/AST/Patch+Contribution+Process].

Please note that once your issue enters an open state it has been accepted. As Asterisk is an open source project there is no guarantee or timeframe on when your issue will be looked into. If you need expedient resolution you will need to find and pay a suitable developer. Asking for an update on your issue will not yield any progress on it and will not result in a response. All updates are posted to the issue when they occur.