Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
11.4k views
in .NET FTP by (740 points)
Hi,

I am in a testing mode. To test my program I am using Qick 'n Easy FTP Server 3.1 Lite [1]. When connecting the timeout does not get thrown clientsided with using the edtFTPnet Version 1.2.6.0.

When the server cut of the connection my .NET program still provides a "IsConnected" == true, but when I like to close the connection a SocketException is thrown because the serverside already disconnected the my client.

Here is the code I use:

        public void Close()
        {
            foreach (FTPConnection connection in connections.Values)
                if (connection.IsConnected)
                    connection.Close();
        }



I expect a disconnecting event when the server cuts of the connection. Shouldn't it do so???

Robert.



PS: I can not send any images, because your imageserver are blocked out of my companies firewall I am working for.


[1] http://www.pablosoftwaresolutions.com/h ... erver.html

17 Answers

0 votes
by (161k points)
Can you post the relevant piece of the log file? I think we might have fixed this just recently, prob not yet released (if it is what I'm thinking of - a 421 sent by the server).
0 votes
by (740 points)
Can you post the relevant piece of the log file? I think we might have fixed this just recently, prob not yet released (if it is what I'm thinking of - a 421 sent by the server).


I will, my system is currently not running.
0 votes
by (740 points)
Can you post the relevant piece of the log file? I think we might have fixed this just recently, prob not yet released (if it is what I'm thinking of - a 421 sent by the server).


It is "426 Connection timed out, aborting transfer" thrown by the server but not acknowledged by the client.

Regards.
0 votes
by (161k points)
We'll need to see the log file at Debug level. Transfers are validated like this:

string code = reply.ReplyCode;
if ((code.Equals("426") || code.Equals("450")) && !cancelTransfer)
throw new FTPException(reply);

So an exception should be thrown here if you have not called CancelTransfer().
0 votes
by (740 points)
We'll need to see the log file at Debug level. Transfers are validated like this:

string code = reply.ReplyCode;
if ((code.Equals("426") || code.Equals("450")) && !cancelTransfer)
throw new FTPException(reply);

So an exception should be thrown here if you have not called CancelTransfer().


I do not know what kind of debug information you like?

But you are welcome to test it your self!

1) Download: http://www.pablosoftwaresolutions.com/download.php?id=7 (ftpserver3lite.zip)
Configure it to 1 minute timeout, set up user and password

2) Using code in a .Net Projekt with your current libs:

The servers trace is:
        
private void button1_Click(object sender, EventArgs e)
{
    FTPConnection c = new FTPConnection();
    c.ServerAddress = "127.0.0.1";
    c.UserName = "testo";
    c.Password = "testo";
    c.Closed += new FTPConnectionEventHandler(c_Closed);
        
    c.Connect();
    System.Diagnostics.Debug.WriteLine("Connected");
}

void c_Closed(object sender, FTPConnectionEventArgs e)
{
    System.Diagnostics.Debug.WriteLine("Connection timed out");
}


c_Closed never gets thrown.


13:47:30.030 [1536] Client connected from 127.0.0.1.
13:47:30.061 [1536] 220 Welcome to Quick 'n Easy FTP Server
13:47:30.061 [1536] USER testo
13:47:30.061 [1536] 331 Password required for testo
13:47:30.061 [1536] PASS *****
13:47:30.077 [1536] 230 User successfully logged in.
13:47:30.077 [1536] TYPE I
13:47:30.077 [1536] 200 Type set to BINARY
13:47:30.077 [1536] PWD
13:47:30.093 [1536] 257 "/" is current directory.
13:47:30.093 [1536] CWD /
13:47:30.093 [1536] 250 "/" is current directory.
13:47:30.093 [1536] PWD
13:47:30.108 [1536] 257 "/" is current directory.
13:48:31.061 [1536] Client disconnected from 127.0.0.1.
13:48:31.061 [1536] 426 Connection timed out, aborting transfer


I've got an additional question: Why do you do PWD, CWD, PWD after a fresh connection?

Regards.
0 votes
by (161k points)
Please set logging to Debug level:

FTPConnection.LogLevel = LogLevel.Debug;
FTPConnection.LogFile = "myfile.log";



I've got an additional question: Why do you do PWD, CWD, PWD after a fresh connection?

Regards.


Get current wd, change to it, and then get it again to record in a variable. Some servers do some weird things here and we've found this works best to get the actual wd.
0 votes
by (740 points)
here is the log of the FTPConnection:

DEBUG [HostNameResolver] 3 Feb 2008 11:46:57.421 : 127.0.0.1 resolved to 127.0.0.1
DEBUG [FTPClient] 3 Feb 2008 11:46:57.421 : Connecting to 127.0.0.1:21
DEBUG [FTPControlSocket] 3 Feb 2008 11:46:57.437 : 220 Welcome to Quick 'n Easy FTP Server
DEBUG [FTPControlSocket] 3 Feb 2008 11:46:57.453 : ---> USER testo
DEBUG [FTPControlSocket] 3 Feb 2008 11:46:57.453 : 331 Password required for testo
DEBUG [FTPControlSocket] 3 Feb 2008 11:46:57.453 : ---> PASS ********
DEBUG [FTPControlSocket] 3 Feb 2008 11:46:57.453 : 230 User successfully logged in.
DEBUG [FTPConnection] 3 Feb 2008 11:46:57.453 : Successfully logged in
DEBUG [FTPControlSocket] 3 Feb 2008 11:46:57.453 : ---> TYPE I
DEBUG [FTPControlSocket] 3 Feb 2008 11:46:57.453 : 200 Type set to BINARY
DEBUG [FTPControlSocket] 3 Feb 2008 11:46:57.453 : ---> PWD
DEBUG [FTPControlSocket] 3 Feb 2008 11:46:57.453 : 257 "/" is current directory.
DEBUG [FTPControlSocket] 3 Feb 2008 11:46:57.468 : ---> CWD /
DEBUG [FTPControlSocket] 3 Feb 2008 11:46:57.468 : 250 "/" is current directory.
DEBUG [FTPControlSocket] 3 Feb 2008 11:46:57.468 : ---> PWD
DEBUG [FTPControlSocket] 3 Feb 2008 11:46:57.468 : 257 "/" is current directory.


The server ran into a timeout. I closed the server after the timeout too. So its process didn't run anymore. Shouldn't you acknowledge a TCPSocket - disconnection?
0 votes
by (161k points)
There should be more than this in the log - no errors are shown here. Where's the 426 error that is being returned to the client?
0 votes
by (740 points)
There should be more than this in the log - no errors are shown here. Where's the 426 error that is being returned to the client?


That is beeing produced on the server side, but not acknowledged on the client side. That is the reason of this thread.

I checked again, but nothing else I can report. I run with LogLevel.All

You can check yourself with downloading the ftp server I mentioned above.

Rov.
0 votes
by (740 points)
Ok,

now I have tried a second server: FileZilla

With this server I get a lot more output:

DEBUG [HostNameResolver] 4 Feb 2008 15:35:38.272 : 0.0.0.0 resolved to 0.0.0.0
DEBUG [FTPClient] 4 Feb 2008 15:35:38.288 : Connecting to 0.0.0.0:21
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.335 : 220-FileZilla Server version 0.9.24 beta
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.335 : 220-written by Tim Kosse (Tim.Kosse@gmx.de)
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.350 : 220 Please visit http://sourceforge.net/projects/filezilla/
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.350 : ---> USER testo
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.366 : 331 Password required for testo
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.366 : ---> PASS ********
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.382 : 230 Logged on
DEBUG [FTPConnection] 4 Feb 2008 15:35:38.382 : Successfully logged in
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.382 : ---> TYPE A
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.382 : 200 Type set to A
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.382 : ---> PWD
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.397 : 257 "/" is current directory.
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.397 : ---> CWD /
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.397 : 250 CWD successful. "/" is current directory.
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.413 : ---> PWD
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.413 : 257 "/" is current directory.
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.413 : ---> CWD /
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.413 : 250 CWD successful. "/" is current directory.
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.413 : ---> PWD
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.429 : 257 "/" is current directory.
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.429 : ---> SYST
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.429 : 215 UNIX emulated by FileZilla
DEBUG [FTPFileFactory] 4 Feb 2008 15:35:38.444 : Selected UNIX parser
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.444 : ---> PWD
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.444 : 257 "/" is current directory.
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.460 : ---> PASV
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.460 : 227 Entering Passive Mode (0,0,0,0,9,169)
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.460 : Server supplied address=0.0.0.0
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.460 : Server supplied port=2473
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.460 : Substituting server supplied IP (0.0.0.0) with remote host IP (0.0.0.0)
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.460 : NewPassiveDataSocket(0.0.0.0,2473)
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.460 : ---> LIST
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.491 : 150 Connection accepted
DEBUG [FTPClient] 4 Feb 2008 15:35:38.491 : Reading ASCII listing data
DEBUG [FTPClient] 4 Feb 2008 15:35:38.491 : -->drwxr-xr-x 1 ftp ftp              0 Jan 09 18:24 DirectoryA
DEBUG [FTPClient] 4 Feb 2008 15:35:38.491 : -->drwxr-xr-x 1 ftp ftp              0 Jan 09 18:24 DirectoryB
DEBUG [FTPClient] 4 Feb 2008 15:35:38.491 : -->drwxr-xr-x 1 ftp ftp              0 Jan 09 18:25 DirectoryC
DEBUG [FTPClient] 4 Feb 2008 15:35:38.491 : -->-r--r--r-- 1 ftp ftp          22326 Mar 23  2007 FileA
DEBUG [FTPClient] 4 Feb 2008 15:35:38.491 : -->-r--r--r-- 1 ftp ftp           2562 Mar 23  2007 FileB
DEBUG [FTPControlSocket] 4 Feb 2008 15:35:38.491 : 226 Transfer OK
DEBUG [FTPClient] 4 Feb 2008 15:35:38.507 : Found 5 listing lines
DEBUG [FTPFileFactory] 4 Feb 2008 15:35:38.507 : Parse() called using culture: Invariant Language (Invariant Country)
DEBUG [FTPControlSocket] 4 Feb 2008 15:37:04.944 : ---> QUIT
ERROR [FTPControlSocket] 4 Feb 2008 15:37:05.147 : Exception in SendCommand : System.IO.IOException: Von der ?bertragungsverbindung k?nnen keine Daten gelesen werden: Eine bestehende Verbindung wurde softwaregesteuert
durch den Hostcomputer abgebrochen.
System.IO.IOException: No data can be read from the transfer connection: An existing connection was canceled software controlled by the host computer.
   bei System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)
   bei System.IO.StreamReader.ReadBuffer()
   bei System.IO.StreamReader.ReadLine()
   bei EnterpriseDT.Net.Ftp.FTPControlSocket.ReadReply()
   bei EnterpriseDT.Net.Ftp.FTPControlSocket.SendCommand(String command)
CAUSED BY:
System.Net.Sockets.SocketException: Eine bestehende Verbindung wurde softwaregesteuert
durch den Hostcomputer abgebrochen
   bei System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   bei System.Net.Sockets.NetworkStream.Read(Byte[] buffer, Int32 offset, Int32 size)



The timeout of the server is put to 30s. "Quit" is triggered manually way after the timeout of the server as you can see. And of course on connection is existing anymore, we can not send any data.

Rov.

Categories

...