Asterisk keeps going through dialplan after "Busy" is received

Hi!

I have an asterisk box for ~40 users and I have a couple of telephony providers using SIP. I have just migrated from Asterisk 13 to Asterisk 20.8.1.
I have the dailplan like this:
exten => _XXXXXXXXXX,1,NoOp(${CALLERID(num)})
exten => _XXXXXXXXXX,n,Dial(PJSIP/${EXTEN}@SP1,25)
exten => _XXXXXXXXXX,n,Dial(PJSIP/${EXTEN}@SP2,25)
exten => _XXXXXXXXXX,n,Hangup()
So if something is wrong with service provider 1, the call will attempt again through service provider 2. It works just fine, however I noticed the following behavior - when the call goes out and is declined by remote party (calling to myself and declining call on my cell phone) asterisk does receive the “Busy” signal from service provider but keeps executing the dialplan:

-- Executing [1111111111@vip:1] NoOp("PJSIP/621-00000291", "621") in new stack
-- Executing [1111111111@vip:2] Dial("PJSIP/621-00000291", "PJSIP/1111111111@SP1,25") in new stack

== Everyone is busy/congested at this time (1:1/0/0)
– Executing [1111111111@vip:3] Dial(“PJSIP/621-00000291”, “PJSIP/1111111111@SP2,25”) in new stack
== Everyone is busy/congested at this time (1:1/0/0)
– Executing [1111111111@vip:4] Hangup(“PJSIP/621-00000291”, “”) in new stack
If a person on remote side is actually busy and can’t talk asterisk will still keep calling even if the call was declined. I don’t remember such a behavior on Asterisk 13 (i might be mistaken though), as far as I remember call was actually ended if it was declined. So basically the question is - how can I make asterisk follow the dialplan in case something is wrong with service provider, but if there was actual user decline on remote side asterisk would just stop the call completely. Is it possible?
I’m not very experienced with asterisk yet so any help will be appreciated.

Thanks in advance.

It’s always worked like that from a dialplan perspective. If you want greater control than there is the DIALSTATUS dialplan variable which is rather broad, or the hangup cause functionality, to allow you to write dialplan to react accordingly. It also depends on the responses you get back from the provider.

[1] Hangup Cause - Asterisk Documentation

So basically the solution should be smth like this?

exten => _XXXXXXXXXX,1,NoOp(${CALLERID(num)})
exten => _XXXXXXXXXX,n,Dial(PJSIP/${EXTEN}@SP1,25)
exten => _XXXXXXXXXX,n,GotoIf($[“${DIALSTATUS}” = “BUSY”|“CANCEL”]?busy:continue)
exten => _XXXXXXXXXX,n(continue),Dial(PJSIP/${EXTEN}@SP2,25)
exten => _XXXXXXXXXX,n,Hangup()
exten => _XXXXXXXXXX,n(busy),Hangup()

You can’t define sets like that. Also, only the caller can cancel, in which case there is no channel to run in the dialplan.

As hinted, you may need to be more specific than DIALSTATUS.

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.