Thanks for your explanation, but it does not solve the problem.
In fact, I get “no such item” error even without using logical operations and searching for a single IP address.
[admin1@MT1] > /ip firewall connection print count-only where dst-address="1.1.1.1"
0
no such item (4)
[admin1@MT1] > /ip firewall connection print count-only where dst-address="1.1.1.1"
0
[admin1@MT1] > /ip firewall connection print count-only where dst-address~"1.1.1.1"
235
no such item (4)
[admin1@MT1] > /ip firewall connection print count-only where dst-address~"1.1.1.1"
436
It is interesting that the problem occurs only in about half the cases.
Also, it is related to the number of entries in the connection table.
The more entries - the higher the probability of “no such item” error.
Likely the “where” clause is walking through the connections list and while it is doing so some connections disappear.
The more users/connections you have, the more likely that probably is to occur.
This is always a problem in such “first/next” walking through lists that are not static.
Whether that should have been covered in RouterOS and handled invisibly from the users is a matter for debate…
The main problem is that this error terminates the script execution and I do not understand how to ignore this error.
Suppose I have this script:
... Some code ....
/ip firewall connection print count-only where dst-address~"1.1.1.1"
Getting "no such item" - Script terminating.
... Some code - 2 ....
The code “Some code - 2” will not be executed.
Is it possible to force ROS ignore “no such item” error and continue code execution?
Thanks for reply.
I tried do {} on-error = {}
But it did not solve my problem.
Code:
:global result
:log info ("Step1")
:do {
:set result [/ip firewall connection print count-only where dst-address~":80"];
} on-error={:log info ("Error1")};
:log info ("Result1: $result")
:log info ("Step2")
:do {
:set result [/ip firewall connection print count-only where dst-address~":80"];
} on-error={:log info ("Error2")};
:log info ("Result2: $result")
Result:
[admin1@MT1] >
17:15:49 echo: script,info Step1
[admin1@MT1] >
17:16:07 echo: script,error script error: no such item (4)
The script is terminated. (((
Is there something wrong with my code?
On the low-loaded Mikrotik this code is executed successfully…