FTP server and the FTP client sample code

Discussion to talk about software related topics only.
Post Reply
dkoste01
Posts: 9
Joined: Thu Apr 12, 2012 8:33 pm

FTP server and the FTP client sample code

Post by dkoste01 »

Hello,
I have been trying to make integrate an update command into my program, basically by merging the FTP Client and SD Update example, so that I can pull updates from a server and store multiple versions on SD card.

An issue which I have encountered is that the FTP Client sample cannot connect to my FireZilla server, even though I changed the parameters to match my servers user. When I looked at a serial output, it returner error -4, which was either FTP_COMMANDFAIL or FTP_COMMANDERROR, and noticed that the server displayed an error "425 Can't open data connection". All the firewalls are off and this is done on the local network so I do not think the router is an issue, even though I set the forwarding up anyways. Does anyone have an idea as to what may be wrong?

Thank you.
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: FTP server and the FTP client sample code

Post by pbreed »

Many FTP systems won't work across a firewall unless you use the passive mode....

IE


call

/*Set FTP in Passive mode for better Firewall behavior*/
void FTPPassiveMode( int ftp_Session );

on the Ftp session before trying to send /rx data.
dkoste01
Posts: 9
Joined: Thu Apr 12, 2012 8:33 pm

Re: FTP server and the FTP client sample code

Post by dkoste01 »

Thank you very much, this has fixed the issue, although I am confused as to how it fixed it. You said that passive mode works better with firewalls, but I did a few tests with the firewall off and it still failed, weird.
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: FTP server and the FTP client sample code

Post by pbreed »

There are likely more firewalls and routers between here and there than you realize.
dkoste01
Posts: 9
Joined: Thu Apr 12, 2012 8:33 pm

Re: FTP server and the FTP client sample code

Post by dkoste01 »

Is there any particular reason why the FTPGetFile works for file sizes up to about 64kb, but when I attempt to transfer an update file 460kb big, I get a "426 Connection Closed" error?
User avatar
pbreed
Posts: 1088
Joined: Thu Apr 24, 2008 3:58 pm

Re: FTP server and the FTP client sample code

Post by pbreed »

That function just returns a file descrptor... something else must actually read the file...
Whatever that code is is probably not handling the large file and closing down early...

Paul
khoney
Posts: 125
Joined: Fri Sep 11, 2009 12:43 pm

Re: FTP server and the FTP client sample code

Post by khoney »

I am also getting error code 425, but only after I have performed a certain number of sequential ftp sessions. It seems that once I enter passive mode with FTPDSess.nSession equal to 27, when I try to retrieve a file, I get the following responses:
150 File status okay; about to open data connection
425 Can't open data connection.

From then on I'm hosed. My command interface works, but the data connections fail.

I'm going to try running in active mode to see if it's just passive mode causing problems. I'm guessing it has something to do with the listener sockets.
khoney
Posts: 125
Joined: Fri Sep 11, 2009 12:43 pm

Re: FTP server and the FTP client sample code

Post by khoney »

***** UPDATE *******

I ran the Auto FTP Manager application overnight using ACTIVE FTP mode and had it pull off generated files from my SD card every two minutes. Everything worked fine, so the problem appears to be related to operation in passive mode. This seems like it would be a problem in the Netburner system library. If anyone has run into this issue, or has NOT run into this issue when performing repeated FTP client sessions to the Netburner server, I would be interested in hearing of your experience.
User avatar
dciliske
Posts: 624
Joined: Mon Feb 06, 2012 9:37 am
Location: San Diego, CA
Contact:

Re: FTP server and the FTP client sample code

Post by dciliske »

There was an issue that has been fixed with the FTP server examples where an abnormal data socket closure would cause the server to not be able to transfer data. This sounds like what you're seeing. What version of the NNDK is your code from?

-Dan
Dan Ciliske
Project Engineer
Netburner, Inc
khoney
Posts: 125
Joined: Fri Sep 11, 2009 12:43 pm

Re: FTP server and the FTP client sample code

Post by khoney »

I was at 2.6. I just purchased a renewal to try updating to 2.7 to see if this issue goes away, but I've been having a lot of issues with the update (see the NNDK update announcement), and haven't gotten back to a buildable app yet. It actually seems to me like it's running out of sockets or some limited resource, becaause it works fine for a number of sessions, but fails after the PASV command response returns a value of 100,27 as the last two octets, 27 being the number that Netburner library appears to auto-increment every time a PASV command is issued.
Post Reply