0
votes

I'm using PHPAGI and I'm having a bit of trouble. I've simplified the problem to only a few lines of code. First, my context:

[script]
exten=>s,1,AGI(asterisk_callback.php)

And my actual code (Using Laravel 4):

Log::info('[callback script] Creating PHPAGI..');
$agi = new AGI();
Log::info('[callback script] Trying noop..');
$agi->noop('Can you see me?');
Log::info('[callback script] Success!');

When I drop a .call file, I do receive a call. Once I answer, my log receives the first two messages. It then hangs on $agi->noop(). My phone call will stay live, and once I hang up the script will continue and log "Success!"

Asterisk has the following log:

Connected to Asterisk 11.7.0~dfsg-1ubuntu1 currently running on playground (pid = 26298)
       > Channel SIP/vitel-outbound-00000000 was answered
    -- Executing [s@callback_script:1] AGI("SIP/vitel-outbound-00000000", "asterisk_callback.php,53,SIP/vitel-outbound-00000000") in new stack
    -- Launched AGI Script /usr/share/asterisk/agi-bin/asterisk_callback.php
       > 0x7f84dc0181d0 -- Probation passed - setting RTP source address to 64.2.142.190:15106

... It freezes here until I hang up the call. Then I get:

    -- <SIP/vitel-outbound-00000000>AGI Script asterisk_callback.php completed, returning 4
  == Spawn extension (callback_script, s, 1) exited non-zero on 'SIP/vitel-outbound-00000000'
[Jun 20 12:33:44] NOTICE[26511]: pbx_spool.c:402 attempt_thread: Call completed to SIP/2144769335@vitel-outbound/n

Am I doing something wrong with phpagi?

1
Update: I traced the problem to the AGI class constructor. It is freezing on fgets(). Apparently it is waiting for standard input to receive something. For giggles I commented it out, but still no luck. Now the script just terminates effective $agi = new AGI()Anthony

1 Answers

0
votes

Found the issue. I'm actually having AGI() call a script, which runs Laravel as an artisan command. I think the problem is that standard input/output aren't being routed to the exec() command in the script. I'll ask the question a different way in a different post.