chan-sccp / PAMI

Fork of PHP Asterisk Manager Interface ( AMI ) supports synchronous command ( action )/ responses and asynchronous events using the pattern observer-listener. Supports commands with responses with multiple events. Very suitable for development of operator consoles and / or asterisk / channels / peers monitoring through SOA, etc
http://marcelog.github.com/PAMI
Apache License 2.0
26 stars 21 forks source link

$asteriskClient->send(new QueueStatusAction()) get error on 2.0.7 #16

Open varlog11 opened 3 years ago

varlog11 commented 3 years ago

Hello!

$asteriskClient->send(new QueueStatusAction()) get error in the version 2.0.7 ERROR: E_ERROR "Uncaught TypeError: Argument 1 passed to PAMI\Client\Impl\ClientImpl::__construct() must be of the type array, null given, called in vendor/chan-sccp/pami/src/PAMI/Client/Impl/ClientImpl.php:571

In the version 2.0.6 everything works fine.

dkgroot commented 3 years ago

I just ran this:

#!/usr/bin/env php
<?php
/**
 * @category   Asterisk / Demo Config MetaData / Pami
 * @package    Simple Config MetaData Demo
 * @author   Diederik de Groot <ddegroot@talon.nl>
 * @license  http://github.com/dkgroot/PAMI Apache License 2.0
 * Copyright 2016 Diederik de Groot <ddegroot@talon.nl>
 */
if ($argc <5 ) {
    echo "Use: $argv[0] <host> <port> <user> <pass>] ";
    echo "example: $argv[0] 192.168.1.20 5038 admin secret
" ;
    exit (254);
}

declare(ticks=1);
require(implode(DIRECTORY_SEPARATOR, array(
    __DIR__,
    'vendor',
    'autoload.php'
)));
use PAMI\Client\Impl\ClientImpl;
use PAMI\Message\Action\QueueStatusAction;

error_reporting(E_ALL);
ini_set('display_errors', 1);
try
{
    $options = array(
        'log4php.properties' => realpath(__DIR__) . DIRECTORY_SEPARATOR . 'log4php.properties',
        'host' => $argv[1],
        'port' => $argv[2],
        'username' => $argv[3],
        'secret' => $argv[4],
        'connect_timeout' => 2,
        'read_timeout' => 2
    );
    $pami = new ClientImpl($options);
    $pami->open();
    $response = $pami->send(new QueueStatusAction());
    var_dump($response);
    $pami->close();
} catch (Exception $e) {
    echo $e->getMessage() . "\n";
}

And it seems to work just fine. Could it be that you forgot:

$asteriskClient= new ClientImpl($options);
$asteriskClient->open();
varlog11 commented 3 years ago

Hello! Thanks for the answer. I tested again on a server with DEBIAN 10, PHP 7.3, asterisk 16.15.0 and 18.2.0 and could not get correct work on version 2.0.7. In the attachment I attach the script output when using version 2.0.6. On version 2.0.7 it gives: Read timeout v_2_0_6.txt

dkgroot commented 2 years ago

Hi Varlog, I have finally gotten around to merging some of the PR's and updating the release to v2.0.10 Would you be able to run to test script i committed above ?