Issues with STOR command from FZ client and custom FTP server

Moderator: Project members

Post Reply
Message
Author
anschrammh
500 Command not understood
Posts: 4
Joined: 2019-10-21 10:32
First name: an
Last name: schramm
Location: France

Issues with STOR command from FZ client and custom FTP server

#1 Post by anschrammh » 2019-10-22 06:13

Hello, everyone.
First of all.
Thank you in advance for all the help you will be able to provide me with.

So here is the situation :

I'am currently developing a FTP server on a MCU (the ESP8266).
In order to be complient with the FTP protocol, I followed the RFC 959 (or at least what I understood of it).
Finally for testing purposes, I'am using FileZilla FTP client.
The only mode supported by the server for now is passive FTP.

Issues
I'am facing 2 issues with the STOR command, (everything else works flowlessly).

The first one is when I create a new file throught the FZ CLient GUI.
I receive the STOR command, but I do not see any connection attempt on the data port (ie no connection after the PASV request).
I was wondering if no connection was established because there is no data to send since the file which is created is empty.
Or if FZ Client opened and closed the connection very quicly.

The second one is when sending a big file from the FZ Client to the server (with STOR again), if the transfer takes longer than the client's timeout (20 secs in my case),
the client thinks the connection was lost and connects again to retry the data transfer.
If I set the timeout to 0 (ie no timeout) the transfer works without errors.
So my question is the following one : should the server give a feedback while receiving a file with the number of bytes received from the client ?
Nothing like this that I have read is specified in the RFC 959.

Again a big thank you to who will take the time to help me.

If you need more information do not hesitate to ask me.
To code or not to code, that is the question.

User avatar
botg
Site Admin
Posts: 35492
Joined: 2004-02-23 20:49
First name: Tim
Last name: Kosse

Re: Issues with STOR command from FZ client and custom FTP server

#2 Post by botg » 2019-10-22 07:44

The establishment of the data connection can happen before or after the STOR command. It can even happen right in the middle, e.g. you could get a TCP segment for "ST", followed by the SYN for the data connection followed by a segment with "OR fileame" [*]

At what rate are you processing data? Unless it's extremely slow (much lower than the amount of data buffered in the network) you shouldn't see a timeout after 20 seconds of starting the transfer.


[*] A common mistake made by embedded device developers, they mistakenly assume TCP segments always contain a single complete FTP command/reply. TCP segments may contain partial and/or multiple commands/replies.

anschrammh
500 Command not understood
Posts: 4
Joined: 2019-10-21 10:32
First name: an
Last name: schramm
Location: France

Re: Issues with STOR command from FZ client and custom FTP server

#3 Post by anschrammh » 2019-10-22 10:53

First of all thank you for your time and your reply,

Regarding the first issue, When I receive the PASV command, I start accepting new connections on the data port (1024 in my case). While I'am accepting, I'am still processing what is coming on the command port (21 in my case), after PASV, I receive the STOR command in this case.

To sum up, I'am listening just after PASV until the client connects to the data port. I get no connection before and after the STOR cmd, even if I wait for a long time.
The issue I described here only happens with empty files, other files work each time.

For the second issue, I'am reading as fast I can, I guess it is limited by the clock of the mcu 80mhz and the write speed to the uSDCard which uses the SPI bus. FileZilla finds an upload speed of around 47 KiloByte/s.

When I read the data port during a file transfer, I usually get between 512 and 1024 bytes of data each time. I can read up to a 2500 Bytes block (my buffer max size). If this helps.

PS: I am french, so sorry for any mistakes I may do.
To code or not to code, that is the question.

User avatar
botg
Site Admin
Posts: 35492
Joined: 2004-02-23 20:49
First name: Tim
Last name: Kosse

Re: Issues with STOR command from FZ client and custom FTP server

#4 Post by botg » 2019-10-22 10:58

Do you start listening before or after sending out the reply to the PASV command? The listening needs to start prior to sending the reply.

User avatar
botg
Site Admin
Posts: 35492
Joined: 2004-02-23 20:49
First name: Tim
Last name: Kosse

Re: Issues with STOR command from FZ client and custom FTP server

#5 Post by botg » 2019-10-22 11:02

In case there is no data connection, what is displayed in FileZilla's message log?

anschrammh
500 Command not understood
Posts: 4
Joined: 2019-10-21 10:32
First name: an
Last name: schramm
Location: France

Re: Issues with STOR command from FZ client and custom FTP server

#6 Post by anschrammh » 2019-10-22 11:33

I'll do more testing based on what you told me so far, and when I'am done, I will get back to you with the logs as well.
I will also check the code to see where I'am starting to listen.
Thanks a lot.
To code or not to code, that is the question.

anschrammh
500 Command not understood
Posts: 4
Joined: 2019-10-21 10:32
First name: an
Last name: schramm
Location: France

Re: Issues with STOR command from FZ client and custom FTP server

#7 Post by anschrammh » 2019-11-18 09:09

Hi again,
first of all, sorry for getting back to botg that late.

After more testing, I discovered that small files aren't being received (not all the time, but sometime - it's quite random) when I use a phone as an access point. When I use a dedicated internet wifi router, this doesn't happen.
Large files aren't affected.

To answer the question :
Do you start listening before or after sending out the reply to the PASV command?
.
I'am listening all the time and I'am only accepting before I send the reply to the PASV command.

Here are the logs :
filezilla.log
FileZilla log
(3.5 KiB) Downloaded 159 times
Finally, knowing that sometimes I do not receive small files, I drop the data connection after 5 seconds and I create an empty file instead.

thanks for reading.
To code or not to code, that is the question.

User avatar
botg
Site Admin
Posts: 35492
Joined: 2004-02-23 20:49
First name: Tim
Last name: Kosse

Re: Issues with STOR command from FZ client and custom FTP server

#8 Post by botg » 2019-11-18 13:16

The log does not show a missing transfer.

Post Reply