BenMenking / routeros-api

Client API for RouterOS/Mikrotik
336 stars 272 forks source link

Commands not executed? #66

Closed istoOi closed 8 months ago

istoOi commented 1 year ago

Hi,

i did a fresh setup of ubuntu 22.04, php 8.1.13 Test Router is ROS 6.43.8. API User has "write" permission.

It seems the connection works since the example below returns "success"


<?php
require('./config.php');
require('./routeros_api.class.php');

$API = new RouterosAPI();
$API->debug = true;

if ($API->connect($ROS_ADDR, $ROS_USER, $ROS_PASS)) {
        echo "success";
        $API->disconnect();
}else{
        echo "unable to connect";
}

?>

But when i try to add a firwall address-list entry nothing happens.

<?php
require('./config.php');
require('./routeros_api.class.php');

$API = new RouterosAPI();
$API->debug = true;

if ($API->connect($ROS_ADDR, $ROS_USER, $ROS_PASS)) {
        echo "success";

        $API->write("/ip/firewall/address-list/add", array(
               "list" => "test_list",
               "address" => "1.2.3.4"
        ));

        $API->disconnect();
}else{
        echo "unable to connect";
}

?>

I only get the connection in the Mikrotik logs and the following debug output

Connection attempt #1 to 1.1.1.1:8728...
<<< [6] /login
<<< [9] =name=API
<<< [23] =password=API
>>> [5/5] bytes read.
>>> [5, 1]!done
Connected...
success<<< [29] /ip/firewall/address-list/add
^C

I also don't get anything with

$API->write('/ip/firewall/address-list/print', false);
var_dump($API->read());
Chupaka commented 1 year ago

Hi. Did you try to add var_dump($API->read()); before $API->disconnect(); to see actual response to your command?

atarist commented 1 year ago

Not working in RO v7, any update?

Chupaka commented 1 year ago

@atarist any logs?

BenMenking commented 8 months ago

No activity.