Dialplan stops if playback interrupted by SIP phone going away

I have a dialplan which includes a subroutine to establish if the outgoing line is available. So, I try to make a call from a SIP phone, call the subroutine and if it finds the line isn’t available and it then plays a message using Playback. If I listen to the complete message the dialplan continues as I would expect but if I drop the call from the SIP phone while the Playback is in progress the dialplan simply stops. Whilst the end result isn’t in any way critical I am just wondering if this is the way it should be.

I am allowing Playback to automatically Answer. I’ve tried Answer followed by ControlPlayback but that does no better.

You are going to have to provide the actual dialplan as what you are doing is not standard.

I won’t bore you with the complete dialplan but I hope the following snips show what is happening.
As a matter of interest, what is not standard about playing a message to a SIP phone because the resource it needs is not available?

exten => checkSIPChannel,1,NoOp(check state of {ARG1} {ARG2})
; first thing is to call the script that finds out the state of the Local/Remote Phone/Line
; Note the :0:-1 in the set is to remove the cr coming back from the script
same => n,Set(StateResult={SHELL(/home/phone/phone_utils.sh SIPStatus{ARG1} -${ARG2:0:1}):0:-1})

same => n,Set(${ARG1}${ARG2}State=${StateResult:1})

; determine which message file to use if we play it
same => n,Set(LocRem={IF(["{ARG1}"="Local"]?{MyLocation}:{OtherLocation})}) same => n,Set(PlayMsg={LocRem}_${ARG2}_NA)

same => n,GotoIf($["${${ARG1}${ARG2}State}"="9"]?playit)

; we get here when the resource is not available so play the relevant message
same => n(playit),Playback(${PlayMsg})
; if the phone is put back on hook before the message completes the dialplan stops
same => n,Return(1)

exten => _X.,1,NoOp(Out via Local line)
; check Local Line state and if not AVAILABLE hangup - the check will play a message
same => n,Gosub(subCheckSIPChannel,checkSIPChannel,1(Local,Line))
same => n,GotoIf(["{LocalLineState}"!=“0”]?HangupLline)
same => n,Dial({SIP_LINE}/{EXTEN},55,t)
same => n(HangupLline),Hangup()

In my experience it’s expected behavior for dialplan to stop executing once the channel is gone.

What are you expecting to occur after the channel has hung up?

I’m not entirely surprised that the dial plan stops but I thought that it might be possible to make it continue so that any tidying up/logging might complete. I just wanted to make sure I hadn’t missed anything.

The “h” extension or hangup handlers[1] are commonly used for such purposes.

[1] https://wiki.asterisk.org/wiki/display/AST/Hangup+Handlers

Yes, but in this case the dialplan stops and therefore never gets to the Hangup

Hangup handlers would still be executed. They are invoked when a channel is hung up - whether it be by Asterisk or by the remote side. The normal dialplan execution would stop, but the hangup handler would still be invoked.

1 Like

Thank you. The problem was that the Playback was in a subroutine which didn’t have an ‘h’ extension as it logically would go back to the calling routine in most cases. By adding an ‘h’ extension within the subroutine the problem has been solved.