Frage

For some reason phpagi script randomly stop's in the middle. This only happens once every 20-50 calls. I was able to notice several such 'fails' realtime in asterisk CLI. No error's were displayed. Script sent several verbose messages until just stopped.

Script is used for billing, it has several while's and sql queries. max execution time set to 30seconds.

I didn't find any errors in the /var/log/messages or /var/log/asterisk/messages

  • Asterisk 1.6.2.24
  • PHP 5.1.6 (cli) (built: Jun 27 2012 12:21:13)

    [context-x]
    exten => 1,1,Dial(SIP/XXXXXX)
    exten => h,1,AGI(script.php)
    

Any ideas why it could just stop for random calls?

Thanks.

UPDATE: I've just noticed that when the problem occurs AGI returns 4:

-- <SIP/xxxxxx-00000185>AGI Script script.php completed, returning 4

What's wrong?

War es hilfreich?

Lösung

From what I'm hearing from your symptoms, it doesn't sound like it's specifically an Asterisk issue, but, could be an issue with your script. Here's a number of tips regarding how I would go about debugging an application without any knowledge of what's happening behind the scenes of the AGI script itself...

Firstly, AGI Script script.php completed, returning 4 means that your script is exiting without a clean exit status code. returning 0 is what you'd like to see. You can see the last exit status code at your bash prompt by running a script and then checking the status code with the $? variable. Like so:

[user@host ~]$ ./script.php
[user@host ~]$ echo $?
0

That's what Asterisk is telling you what happened to your script. Anything non-zero is "something's wrong here". Generally, you can customize these to your liking, so specifically 4, I'm not sure.

One thing you'll want to do is turn on agi debugging like so:

host*CLI> agi set debug on

Then run your script, and see if you can find that your php script is spitting out any errors.

Another recommendation that I would have is to make sure your php is logging to your syslog so that you can find errors in /var/log/messages. You can do this by setting in your /etc/php.ini this line:

error_log = syslog

Lastly, to try to replicate the error, I would suggest using a development box, and originate a bunch of calls for yourself, and build a script to create a bunch of "call files".

Here's a call file to get you started:

Channel: LOCAL/100@mycontext
MaxRetries: 2
RetryTime: 60
WaitTime: 30
Application: Wait
Data: 30

When you've created a file, move it to /var/spool/asterisk/outgoing (Moving is important, you want the pointer move, because asterisk may pick up the file too soon if you're writing to it in that directory first).

You can also originate a call on an extension from the CLI:

host*CLI> channel originate LOCAL/100@mycontext application Wait 5

You may also want to use other options in the call file, such as CallerID: John Doe <8005551212> in order to feed interesting data to your AGI application while you create tests to replicate the issue.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top