Chris Blunt
2006-Nov-30 02:50 UTC
[asterisk-users] AGI PHP Issues (AGI script runs but phone hangs up too quickly)
Sorry to re-post this but I'm sure it's something simple that someone has found before. To summarise: Dial plan answers the phone AGI script executes AGI debug in console show phonetics ABC - However no audio at all on the phone and this step is less than 1 second. Dial plan Busy Phone hangs up. Total time less than a second. This is such a simple AGI script do I need the PHPAGI Library - this seems like a sledgehammer to crack a peanut. Thanks again. Original post: I am attempting my first go at a simple AGI application using PHP (Getting Asterisk to SAY PHONETIC ABC). I have dabbled with PHP but I am by no means a professional standard developer. My script seems to execute ok, and I can see asterisk playing the sounds but my phone goes from ringing to busy, and I don't hear the phontics. Below are the relevant bits from my PHP, Console, and extensions.conf. I would be most grateful if someone could show me the way. Thanks in advance: Chris Asterisk ver: 1.2.10 PHP: #!/usr/local/php/bin/php -q <?php $stdin = fopen('php://stdin', 'r'); $stdout = fopen('php://stdout', 'w'); $stdlog = fopen('/var/log/asterisk/my_agi.log', 'w'); while (!feof($stdin)) { $temp = fgets($stdin); $temp = str_replace("\n","",$temp); $s = explode(":",$temp); $agivar[$s[0]] = trim($s[1]); if (($temp == "") || ($temp == "\n")) { break; } } fputs($stdout,"SAY PHONETIC \"abc\" \"#\" \n"); fflush($stdout); $msg = fgets($stdin,1024); fputs($stdlog,$msg . "\n"); ?> Extensions.conf: exten => 4343,1,Answer exten => 4343,2,AGI(example.php) exten => 4343,3,Busy AGI Debug: AGI Rx << SAY PHONETIC "abc" "#" -- Playing 'phonetic/a_p' (language 'en') -- Playing 'phonetic/b_p' (language 'en') -- Playing 'phonetic/c_p' (language 'en') -- AGI Script example.php completed, returning 0 -- Executing Busy("SIP/4321-081b9498", "") in new stack -------------- next part -------------- An HTML attachment was scrubbed... URL: http://lists.digium.com/pipermail/asterisk-users/attachments/20061130/fc3183d3/attachment.htm
Tony Mountifield
2006-Nov-30 09:54 UTC
[asterisk-users] Re: AGI PHP Issues (AGI script runs but phone hangs up too quickly)
In article <001c01c71464$f07ce2f0$631010ac@eitnb440101>, Chris Blunt <chris.blunt@entropy-it.com> wrote:> Sorry to re-post this but I'm sure it's something simple that someone has > found before. > > To summarise: > > Dial plan answers the phone > > AGI script executes > > AGI debug in console show phonetics ABC - However no audio at all on the > phone and this step is less than 1 second. > > Dial plan Busy > > Phone hangs up.Perhaps Asterisk is playing the phonetics in the background (like Background instead of like Playback)? Try putting a Wait(5) after the AGI (or even a sleep(5) within it), to see. General question for anyone that knows: Is there a way in the Dialplan or or in AGI to wait for Background messages to finish playing? Perhaps doing a Playback of a file containing a very short length of silence? Cheers Tony -- Tony Mountifield Work: tony@softins.co.uk - http://www.softins.co.uk Play: tony@mountifield.org - http://tony.mountifield.org