embeddedmz / ftpclient-cpp

C++ client for making FTP requests
MIT License
204 stars 65 forks source link

Ubuntu 20.04 :Upload file to NAS FTP server failure #50

Closed tuanphan1790 closed 1 year ago

tuanphan1790 commented 1 year ago

Hi,

Thanks for your work,

I have a problem when I try to upload a file to NAS server over FTP protocol with port 3090. This is the log file I get in debug mode

`[DEBUG] cURL debug log [0]: - Trying ServerAddress:3090...

[DEBUG] cURL debug log [1]: - 257 "/folderTest/aaa" - Directory successfully created

[DEBUG] cURL debug log [2]: - CWD aaa

[DEBUG] cURL debug log [1]: - 250 CWD command successful

[DEBUG] cURL debug log [2]: - EPRT |1|192.168.0.100|53839|

[DEBUG] cURL debug log [1]: - 500 Illegal EPRT command

[DEBUG] cURL debug log [0]: - disabling EPRT usage [DEBUG] cURL debug log [0]: - Hostname 192.168.0.100 was found in DNS cache [DEBUG] cURL debug log [2]: - PORT 192,168,0,100,199,61

[DEBUG] cURL debug log [1]: - 500 Illegal PORT command

[DEBUG] cURL debug log [0]: - Failed to do PORT [DEBUG] cURL debug log [0]: - Remembering we are in dir "//folderTest//aaa//" [DEBUG] cURL debug log [0]: - Uploaded unaligned file size (0 out of 4212503 bytes)`

Making a folder on the server is ok but uploading file is a failure. It looks like port 3090 was denied on the server.

But when I try to use the command "curl -p --insecure "ftp://file_remote" --user "user:password" -T "file_local", it's ok.

Any solution was appreciated!

I'm using curl version 7.68.0

Thanks so much,

embeddedmz commented 1 year ago

Hello,

I did a web search on "500 Illegal PORT command" and it seems to be related to FTP mode (active/passive).

If you are in active mode, try to disable active mode ftpClient.SetActive(false) otherwise try to enable it ftpClient.SetActive(true).

I hope this helps.

tuanphan1790 commented 1 year ago

Hi embeddedmz,

It's work for me! Thanks so much