Open Source Training Seminar FreePBX Paid Support

Ticket #2880 (new Feature Requests)

Opened 2 months ago

Last modified 4 weeks ago

small fix for phpagi included in freepbx

Reported by: vieri Assigned to: _xo_
Priority: minor Milestone: 3.0
Component: Asterisk API Version: 2.4-branch
Keywords: Cc:
Confirmation: Need Feedback SVN Revision (if applicable):
Backend Engine: All Backend Engine Version:

Description

A small fix in the phpagi code shipped with freepbx can avoid some unwanted connection timeouts.

File:

/var/www/localhost/htdocs/freepbx/admin/modules/framework/agi-bin/phpagi-asmanager.php

Within function:

function connect($server=NULL, $username=NULL, $secret=NULL)

change these lines (which modify fsockopen by adding a connection timeout and insert stream_set_timeout for read/write timeouts):

      $this->socket = @fsockopen($this->server, $this->port, $errno, $errstr, 10);
      if($this->socket == false)
      {
        $this->log("Unable to connect to manager {$this->server}:{$this->port} ($errno): $errstr");
        return false;
      } else
        stream_set_timeout($this->socket, 2);

Add TRUE to the disconnect funcion here:

      // login
      $res = $this->send_request('login', array('Username'=>$username, 'Secret'=>$secret));
      if($res['Response'] != 'Success')
      {
        $this->log("Failed to login.");
        $this->disconnect(TRUE);
        return false;
      }

Finally, modify the disconnect function:

    function disconnect($dontlogoff=NULL)
    {
      if (!$dontlogoff)
        $this->logoff();
      fclose($this->socket);
    }

This is just a suggestion but these small changes actually help when there are transient AMI login problems. Some of my custom phpagi scripts went (seldom) into a 100% CPU consumption state because they hung on $this->logoff(); when fsockopen had returned TRUE.

I could discuss this on the phpagi SF bug tracker but its development seems at a stop since 2005. Also, freepbx has phpagi incorporated.

Change History

07/25/08 19:38:06 changed by p_lindheimer

  • confirmation changed from Unreviewed to Need Feedback.
  • type changed from Bugs to Feature Requests.
  • milestone changed from Cut Line to 3.0.

if you can provide a patch file to try this out we can review. Thanks.

Donate



Support
Download
Develop
Forums
News
Documentation
Paid Support
About

Paid Ads