Hello!
In process of setup Dude SMS notification using fetch tool we noticed that it fail on 202 HTTP response code from the web server. As a result script fails and stop.
According to the Wikipedia: List of HTTP status codes:
This class of status codes indicates the action requested by the client was received, understood, accepted, and processed successfully.
We have performed simple tests using service http://httpstat.us:
tool fetch url="http://httpstat.us/200"
status: finished
downloaded: 0KiBC-z pause]
total: 0KiB
duration: 1s
tool fetch url="http://httpstat.us/202"
status: failed
failure: closing connection: <202 Accepted> 23.99.0.12:80 (4)
200 OK - status: finished
201 Created - status: failed
202 Accepted - status: failed
203 Non-Authoritative Information - status: failed
204 No Content - status: failed
205 Reset Content - status: failed
206 Partial Content - status: failed
The question is if this behavior is correct?
For example wget:
wget http://httpstat.us/202
echo %errorlevel%
0
#
wget http://httpstat.us/404
echo %errorlevel%
8
From Mikrotik support I get the following workaround:
:do {<SOME COMMAND>} on-error={:put command failed, continue script}
And also found some recent discussion on the forum:
- using /tool fetch to create a connection check script
- How to verify result of fetch upload to FTP server?
As a result, if we need to run same request 2 time, we can try to use something like this:
:do {
/tool fetch url="http://httpstat.us/202" keep-result=no
} on-error={
/tool fetch url="http://httpstat.us/202" keep-result=no
}
If we need to run it 3 time:
:do {
/tool fetch url="http://httpstat.us/202" keep-result=no
} on-error={
:do {
/tool fetch url="http://httpstat.us/202" keep-result=no
} on-error={
/tool fetch url="http://httpstat.us/202" keep-result=no
}
}
Thank you!