ArxOne / FTP

Simple FTP client
MIT License
37 stars 15 forks source link

Connection (not using a session) breaks when server issues a broadcast message #19

Closed ontytoom closed 8 years ago

ontytoom commented 8 years ago

The errors that appear as as follows (first few lines are normal output, but then errors appear once the message was sent by the server):

......
16
16
16
16
16
16
Expected other reply than 214 ('test2')
Expected other reply than 214 ('test2')
File error. Code=150 ('Opening ASCII mode data connection for /bin/ls (998 bytes).')
File error. Code=150 ('Opening ASCII mode data connection for /bin/ls (998 bytes).')
Connection error. Code=226 ('Transfer complete (20.792 KB/s).')
Connection error. Code=226 ('Transfer complete (21.234 KB/s).')
Socket error to localhost
Socket error to localhost
Socket error to localhost
Socket error to localhost
Socket error to localhost
Socket error to localhost
Socket error to localhost
Socket error to localhost
Socket error to localhost
Socket error to localhost
Socket error to localhost
Socket error to localhost
Socket error to localhost
Socket error to localhost
Socket error to localhost
Socket error to localhost
.....
ontytoom commented 8 years ago

The following is the first exception is caught by the calling code:

An unhandled exception of type 'ArxOne.Ftp.Exceptions.FtpProtocolException' occurred in ArxOne.Ftp.dll
Additional information: Expected other reply than 214 ('test')
ontytoom commented 8 years ago

This was tested using Xlight FTP server (http://www.xlightftpd.com/) running locally on my Windows laptop.

ontytoom commented 8 years ago
            FtpClient ftp = new FtpClient( FtpProtocol.Ftp, "localhost", 21, new System.Net.NetworkCredential( "someuser", "somepasswd" ) );

            for ( int i = 0; i < 100; i++ )
            {
                IEnumerable<FtpEntry> list;

                try
                {
                    list = ftp.ListEntries( "/" );
                    DebugPrintln( list.ToArray().Count().ToString() );
                }
                catch ( Exception ex )
                {
                    DebugPrintln( ex.Message );
                }

            }

(DebugPrintln is any reporting function of your choice.)

While this code is looping, I used the FTP server "send broadcast message" function and sent message "test".

picrap commented 8 years ago

It appears that the 214 reply code is the answer to a HELP command. I couldn't find any specification regarding this. Do you have some documentation about this?

ontytoom commented 8 years ago

Hello, unfortunately I do not. I have merely noticed that once the this happens, my FTP client keeps receiving errors and I don't seem to have a way to fix that.

Do you have any suggested way to reset the connection one this occurs?
Is there any function I can call in order to reset connection?

Thank you :-)

picrap commented 8 years ago

I downloaded xlight ftp, but I can't find where is this broadcast option (I downloaded the standalone version).

picrap commented 8 years ago

Found it! I'm investigating :thought_balloon:

picrap commented 8 years ago

It can't be solved directly, because it creates a shift between commands and replies. So the only way is to invalidate the session. I'm currently searching for an elegant way to do this without the need to expose the FtpSession. Hang tight :wink:

picrap commented 8 years ago

Fixed in 1.8.

ontytoom commented 8 years ago

Thank you kindly :-)