Community discussions

MikroTik App
 
AlpeRa
just joined
Topic Author
Posts: 1
Joined: Tue Dec 23, 2008 8:54 am

PHP API BUG ??

Tue Dec 23, 2008 9:18 am

[29] => Array
(
[.id] => *2A
[disabled] => no
[invalid] => no
[dynamic] => no
[name] => Queue1
[] => target-addresses
[255.1xx.xxx/32,88.255.1xx.xxx/32,88.255.1xx.xx] =>
[/32,88.255.1xx.xxx/32,88.255.1xx.xxx/32,88.255.1xx.] =>
[xx/32,88.255.1xx.xxx/32,88.255.1xx.xxx/32,88.255.] =>
[05.xxx/32] => dst-address
[0.0] => interface
[th
] => priority
[t-small!r] => .id
[29] => dst-address
[interface] => all
[e] => default-small/default-small
[led] => no

[.0.0.0/0] => dst-netmask
[ent] => TOPLAM
[default-small!r] => .id
[55.155.58/32] => dst-address
[0.0.0] => interface
[both
] => priority
[0/0] => max-limit
[isabled] => no

[0] => dst-netmask
[PLAM] => direction
[0] => max-limit
] => .id
[.128/27,212.175.xxx.xxx/28] => dst-address
[dst-netmask] => 0.0.0.0
[
] => priority
)


when i try to get data with multiple target-addresses from queue , i got the problem

how can i fix it?

when i try it with single target-address, it works

[30] => Array
(
[.id] => *32
[disabled] => no
[invalid] => no
[dynamic] => no
[name] => Queue2
[target-addresses] => 88.255.1xx.xx/32
[dst-address] => 0.0.0.0/0
[dst-netmask] => 0.0.0.0
[interface] => all
[parent] => TOPLAM
[direction] => both
[priority] => 8
[queue] => default-small/default-small
[limit-at] => 0/0
[max-limit] => 0/0
[total-queue] => default-small
)
 
moly
newbie
Posts: 44
Joined: Tue Dec 06, 2005 3:14 pm
Contact:

Re: PHP API BUG ??

Wed Jan 28, 2009 2:00 pm

Hi, I have the same problem. I try 3.15 and 3.19.

Error print :
!re >>> [8, 24] =.id=*19 >>> [9, 14] =comment= >>> [9, 4] =name=VPN >>> [128, 719] �=target-addresses=10.1.1.222/32,10.1.1.223/32,10.1.1.224/32,10.1.1.225/32,10.1.1.226/32,10.1.1.227/32,10.1.1.228/32,10.1.1.229/ >>> [51, 667] 2=dst-address=0.0.0.0/0=interface=all=parent=SG >>> [79, 587] slavany=direction=both=priority=5=queue=default/default=limit-at=256000/256 >>> [48, 538] 00=max-limit=8000000/8000000=burst-limit=0/0= >>> [98, 439] urst-threshold=0/0=burst-time=0s/0s=total-queue=default�!re=.id=*1A =comment= =name=VoIP_x1-=t >>> [97, 341] rget-addresses=10.1.1.240/32,10.1.1.241/32=dst-address=0.0.0.0/0=interface=all=parent=SG Oslav >>> [97, 243] ny=direction=both=priority=1"=queue=default-small/default-small =limit-at=0/0=max-limit=256000 >>> [47, 195] 256000=burst-limit=0/0=burst-threshold=0/0=b >>> [117, 77] rst-time=0s/0s=total-queue=default-small�
 
moly
newbie
Posts: 44
Joined: Tue Dec 06, 2005 3:14 pm
Contact:

Re: PHP API BUG ??

Wed Jan 28, 2009 3:27 pm

I found error in read function. Problem with length calculation. This function work fine.

function read($parse = true) {

$STATUS = socket_get_status($this->socket);

$RESPONSE = array();

stream_set_timeout($this->socket, 2);

while (true) {

$tmp = ord(fread($this->socket, 1));

if ($tmp < 0x80) {
$LENGTH = $tmp;
} elseif ( $tmp < 0xC0) {
$tmp2 = ord(fread($this->socket, 1));
$LENGTH = ((($tmp*0x100)+$tmp2) ^ 0x8000);
} elseif ( $tmp < 0xE0 ) {
$tmp2 = ord(fread($this->socket, 1));
$tmp3 = ord(fread($this->socket, 1));
$LENGTH = ((($tmp*0x10000)+($tmp2*0x100)+$tmp3) ^ 0xC00000);
} elseif ( $tmp < 0xF0 ) {
$tmp2 = ord(fread($this->socket, 1));
$tmp3 = ord(fread($this->socket, 1));
$tmp4 = ord(fread($this->socket, 1));
$LENGTH = ((($tmp*0x1000000)+($tmp2*0x10000)+($tmp3*0x100)+$tmp4) ^ 0xE0000000);
}

if ($LENGTH > 0) {

$_ = fread($this->socket, $LENGTH);

$RESPONSE[] = $_;

}

$STATUS = socket_get_status($this->socket);

if ($LENGTH > 0)
$this->debug('>>> [' . $LENGTH . ', ' . $STATUS['unread_bytes'] . '] ' . $_);

if ( (!$this->connected && !$STATUS['unread_bytes']) || ($this->connected && $_ == '!done' && !$STATUS['unread_bytes']) )
break;

if (($LENGTH == 0) and $STATUS['timed_out'])
break;

}

if ($parse)
$RESPONSE = $this->parse_response($RESPONSE);

return $RESPONSE;

}
 
stealth
newbie
Posts: 30
Joined: Fri May 26, 2006 4:55 pm

Re: PHP API BUG ??

Sun Feb 01, 2009 3:57 pm

Hi,
thanks for your fix for php read method. Right now I found out that there is some performance issues that some of you may also have.
It seems that certain commnans are very slow due to attempt to fread where there is no data.
/ip/firewall/filter/add=chain=FILTER-IN=dst-address=10.154.114.229=action=accept
/ip/firewall/filter/add=chain=FILTER-OUT=src-address=10.154.114.229=action=accept
/ip/firewall/filter/add=chain=FILTER-IN=dst-address=10.154.114.227=action=accept
/ip/firewall/filter/add=chain=FILTER-OUT=src-address=10.154.114.227=action=accept
each command sequence is blocked for 3 seconds which is default timeout value setted. I tried to add following condition at the end of while cycle, but in some cases it returns without data read, which are read in next read execution, so I get wrong response.
if (($LENGTH == 0 && !$STATUS['unread_bytes'])) {
   break;
}
Does anyone solved this performance issue ?

Who is online

Users browsing this forum: No registered users and 19 guests