I am working with the API to create an application to initiate a file upload to a custom FTP server (hosted by the same application).
It all worked nicely, until I accidentally deleted the file I had been testing it with and tried again.
I have narrowed down the problem to being in the way the router initiate the FTP session.
Router info:
- RouterOS version: 6.33.3 (stable)
Reproductive steps:
- Make sure “nonexistant.txt” does not exist on the router.
- Start FTP server.
- Attempt upload using the below CLI command.
CLI command:
{
:local filename "nonexistant.txt"
:local serverip "192.168.0.42"
:local user "Router"
:local pass "Router"
/tool fetch mode=ftp upload=yes user=$user password=$pass address=$serverip src-path=$filename dst-path=$filename
}
Expected:
The CLI command to give an error and not attempt the FTP session at all.
What Happened:
FTP data transfer is started and then ended immediately.
Both Microsoft’s FTP server and my custom FTP server actually creates an empty file, which I guess makes sense given that the data transfer was started but didn’t transfer anything.
CLI reply:
status: failed
failure: cannot open file
FTP communication:
FTP Client: USER Router
FTP Server: 331 Username ok, need password.
FTP Client: PASS Router
FTP Server: 230 User logged in.
FTP Client: TYPE I
FTP Server: 200 OK
FTP Client: PASV
FTP Server: 227 Entering Passive Mode (192,168,0,42,235,20)
FTP Client: STOR nonexistant.txt
FTP Server: 150 File status okay; about to open data connection
*** Connection closed without warning ***