phpmysqlasteriskvoipelastix

Longer than usual phpagi running time


I'm using some PHPAGI in asterisk that are working on some servers. But when I used them in my new server they worked like usual for only 3 days and now they take longer than expected. Here is a sample.
Any suggestion is appreciated.

#!/usr/bin/php -q
<?php
require('phpagi.php');
error_reporting(E_ALL);
$agi = new AGI();
$_callerId = $agi->get_variable("CALLERID(num)");
if(strlen($_callerId)>4)
{
  $con=mysqli_connect(SomeServer);
  $result = mysqli_query($con,"Select caller_id,extention from record_call order by id desc limit 50");

  while($row = mysqli_fetch_array($result)) {
  $tempCallerId = $row['caller_id'] ;
  $tempExtention = $row['extention'] ;
  if($tempCallerId==$_callerId)
  {
    $agi->set_variable('exExtention',$tempExtention);
    mysqli_close($con);
    return;
  }
};
$agi->set_variable('exExtention','new');
mysqli_close($con);

?>

Solution

  • I got it. Connecting to MySQL took more than usual and it was because of the dns set in elastix. I removed it and now it's working as expected.