I have the following problem with Dial(). I need to dial a particular phone number and before the calls are bridged I want to execute a routine in the new call. I do something like this:
I’m having problem with this edge case:
- The new call is answered
- the routine is getting executed
- the original call is hung up before the routine finishes
Afterwards, the original call is cancelled but the new call still keeps going because of the subroutine. The subroutine is playing the same message in a loop forever until the user on the other side does not press “1”. This means that if the user never presses 1 the call keeps going forever until the user won’t hang up.
The behaviour that I would like to achieve is that when the original call is hung up, the new call is also hung up. It’s kind of weird that Dial() does not do that but I think it is because of the subroutine. It tried to achieve this behaviour using AMI by sending “Hangup” to the new channel. Unfortunately, this is just going to stop the routine so the message won’t be played but it won’t hangup the call. I can see that asterisk stops playing the audio but it won’t send SIP BYE to end the call. Do you have an idea how to fix this?