[Asterisk-Users] PHP/AGI Problem
Alex Barnes
abarnes at ubiquitysoftware.com
Thu May 26 01:47:09 MST 2005
> -----Original Message-----
> From: Jon Farmer [mailto:viperdude_uk at yahoo.co.uk]
> Sent: 26 May 2005 08:47
> To: Moises Silva; Asterisk Users Mailing List -
> Non-Commercial Discussion
> Subject: Re: [Asterisk-Users] PHP/AGI Problem
>
>
> The numbers are read out continuously as expected but If the caller
> hangs up the app does not exit. The console log say the
> caller hung up
> but the app still shows in the process list. The same happened if I
> changed the PHP script in the same way.
>
> I am therefore assuming that AGI expects the script to detect
> the caller
> hung up and to act accordingly. Therefore I guess my question
> is how do
> I detect the caller hungup while a AGI script is running?
>
> Regards
>
> Jon
That is what I was guessing to be the problem.
Normal browser interaction is, PHP script continues to execute until one
of two things happens.
A) The script completes processing
B) The browser kills the TCP connection to the web server / user presses
stop / moves to a different page
Your problem is you don't want A) to ever happen cos it's a continuous
loop.
And B) never happens because asterisk seems to never kill an AGI
connection when user hangs-up.
So worse than just taking up resources on your web server / plain PHP
server you are probably taking up
resources on your asterisk too.
You might want to try adding in some file logging and before & after
each potentially blocking line,
for example the read DTMF line, print out some debug to file.
I suspect you might find that the script isnt blocked its just looping
happily forever.
Assuming the above is true I think there could be an error in your
script maybe?
But I have never used phpagi() before (easier to write my own class) so
this is just a guess.
Currently after:
$res = $agi->agi_getdtmf(1,10000,$term,$prompt=FALSE);
You test for no DTMF and then simply return null.
Instead you could call the other piece of code you have:
$status = $agi->agi_channel_status($agi->request["agi_channel"]);
$agi->conlog("Status code: " . $status["status"]);
$agi->conlog("Description: " . $status["description"]);
if($status["description"] != "Line is up") {
exit();
}
Information contained in this e-mail and any attachments are intended for the use of the addressee only, and may contain confidential information of Ubiquity Software Corporation. All unauthorized use, disclosure or distribution is strictly prohibited. If you are not the addressee, please notify the sender immediately and destroy all copies of this email. Unless otherwise expressly agreed in writing signed by an officer of Ubiquity Software Corporation, nothing in this communication shall be deemed to be legally binding. Thank you.
More information about the asterisk-users
mailing list