Dialplan continue execution while caller hangup

Hi
I have this dialplan below. My problem is that if the phone that dials 313 hangup, the script “call_multiple_numbers.php” will stop execution, and eventually end a loop that calls multiple numbers. Is it possible for the php script to continue running even if the caller who dials 313 hangup the call?

> exten => 313,1,Answer
> same=>2,Wait(2)
> same=>3,AGI(/var/lib/asterisk/agi-bin/call_multiple_numbers.php)
> same=>4,Hangup

The problem lies within the script, but you haven’t provided us with its contents!

I have assumed that you meant that the caller was hung up by Asterisk, when it should not have been. Obviously, if the caller themselves hangs up, there is no way they can continue calling anyone else. That’s a fundamental telephony thing and not something imposed by Asterisk.

Hi @david551 thanks for the reply.
The caller actually does not talk to the thousands of recipients, he only issue the call to record a message and get the script to run and call each number from the database and playback the recorded message to the recipient.

Below is the content of call_multiple_numbers.php

#!/usr/bin/php -q
<?php

ini_set( "include_path", "/var/lib/asterisk/agi-bin/" );
      
require('phpagi.php');   
$agi = new AGI();
$agi->answer();

$stmta2 = $mysqli->prepare("SELECT phone FROM receipients");
$stmta2->bind_param('i',$vaal);
$stmta2->execute();
$stmta2->store_result();
$stmta2->bind_result($phone_number);
while($stmta2->fetch()){	'
include('/var/www/callout.php');  //uses fsockopen() to connect to AMI and cal a number
}


?>

Please explain in detail what you are trying to accomplish.

It sounds like you want to start an AGI by calling an extension and then hang up while the AGI calls multiple numbers. Odd, but if you trap the SIGHUP Asterisk sends to the AGI on hangup, I guess you could do that. I think there’s a setting to ask Asterisk to not send SIGHUP as well.

  1. Is $agi used by callout.php?
  1. I don’t see any question marks to tell MySQL where to bind $vaal.
  2. Wherre is $vaal defined?

I would have thought that creating call files was easier and more reliable than, presumably, using multiple AMI calls to run Orignate…

You need to achieve DeadAGI type processing by ignoring SIGHUP, if your origination processing is long running.

Yes that exactly what i want to accomplish.
Ok i will trap the SIGHUP; I will use deadAGi as @david551 suggested.

No, $agi is not used by callout.php
There is actually a where clause in the SELECT query i did edit it.

For this use case, i want the the callout to be initiated by someone using his cell phone.
Also the thousands of people who receive the call, should have the option to press a key end the end of the message, to listen to the message again. I don’t think this can be achieved with call files?

Thanks, i will read about DeadAGI and try to use it.

DeadAGI is no longer distinct from AGI. The key difference is the handling of SIGHUP.

This sounds like an ideal application for call files.

I agree call files are easier. I think AMI may be more reliable because you get better error feedback.

Do you have permission from these thousands of people or are you in a jurisdiction where that is not a crime against humanity?

Sure. For the second ‘leg,’ specify the context, extension, and priority of a dialplan to handle it.

Using ‘include’ in a loop seems weird to me.

Hi thanks for the info.
Am now able to trap the SIGHUP using the PHP pcntl_signal function.

About the thousands of people who receive the call, we will get their permission before calling them.