Menu

#11 Error while closing the connection.

open
nobody
None
5
2006-03-31
2006-03-31
Kaushik
No

Hi

I am using the FTP Client Library for 1.3.3 released.

I am getting "Server does not return message to the
message" while closing the FTP connection.

When i try this on my FTP on my local machine it works
fine. Only when i try to Close connection with the
remote ftp sites i get this error. It fails in the
FTPConnection.Read() method. I have tried this with 3-
4 FTP sites and i get the ame error during closing
connection.

Please let me know if there is some fix for this and
if not most likely cause for this problem.

Thanks in Advance

Regards
Kaushik

Discussion

  • Nobody/Anonymous

    Logged In: NO

    I have the same problem... have a solution???

     
  • Thomas LaFreniere

    Logged In: YES
    user_id=365682
    Originator: NO

    I ran into the same issue, this is because SendCommand is used within the Close method to close the connection. The default behavior for the SendCommand method is to return the result of the Read method and because you are sending a command to QUIT the server closes the connection before you can read and causing an exception to occur on the Read.

    I did a quick work around on this and basically just duplicated the SendCommand code in the Close method minus the Read part. Eg:

    <code>

    public virtual void Close()
    {
    //ArrayList messageList = new ArrayList();

    if(this.tcpClient != null )
    {
    //messageList = SendCommand("QUIT");

    NetworkStream stream = this.tcpClient.GetStream();
    this.activeConnectionsCount++;

    Byte[] cmdBytes = Encoding.ASCII.GetBytes(("QUIT\r\n").ToCharArray());
    stream.Write(cmdBytes, 0, cmdBytes.Length);

    this.activeConnectionsCount--;

    stream.Close();

    if(this.tcpClient.Connected)
    this.tcpClient.Client.Close();
    this.tcpClient.Close();
    }
    }

    </code>

    I also added line 18 & 19 there to ensure that our underlying socket gets closed, its likely not going to be connected because technically it has just been closed on the line right above it, but in the case you have async calls or something.

    Disclaimer!! I am not an official contributer to this project nor have I fully tested this implementation. It has worked in my own environment within my own circumstances but it may not work for anyone else. Please use at your own risk and if it causes problems it is no fault of myself or the author of this project.

     

Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.