The socket is not connected

Aug 16, 2012 at 12:11 PM

When trying to get the directory list I get the following exception:

Exception; System.Net.Sockets.SocketException: The socket is not connected

 

From the log I can see that there has been a connection as the directory structure is indeed read - from the log:

> 220 (vsFTPd 2.3.2)
< AUTH TLS
> 530 Please login with USER and PASS.
< AUTH SSL
> 530 Please login with USER and PASS.
< USER anonymous
> 331 Please specify the password.
< PASS [omitted for security]
> 230 Login successful.
< FEAT
> 211-Features:
>  EPRT
>  EPSV
>  MDTM
>  PASV
>  REST STREAM
>  SIZE
>  TVFS
>  UTF8
> 211 End
< OPTS UTF8 ON
> 200 Always in UTF8 mode.
< PWD
> 257 "/"
< TYPE A
> 200 Switching to ASCII mode.
< PASV
> 227 Entering Passive Mode (10,28,10,101,206,196).
< LIST /
> 150 Here comes the directory listing.
Thread started: 
Thread started: 
> drwxr-xr-x    3 0        0            4096 Aug 14 09:53 dir1
> drwxr-xr-x    2 0        0            4096 Aug 14 09:53 dir2
> -rw-r--r--    1 0        0               0 Aug 14 09:52 file1.txt

Coordinator
Aug 16, 2012 at 1:02 PM

Looks as though the data connection is being terminated early.  Do you mind posting some code, it's really hard to make a diagnosis as to why this might be happening otherwise.

Aug 17, 2012 at 12:29 PM

 

FtpClient ftpClient = new FtpClient ("dummy", "dummy", "debian");

Console.WriteLine ("Setting object properties");

ftpClient.FtpLogStream = Console.OpenStandardOutput();

ftpClient.FtpLogFlushOnWrite = true;

ftpClient.DataChannelType = FtpDataChannelType.Passive;

Console.WriteLine("Connecting");

ftpClient.Connect();



try {

Console.WriteLine ("Requesting directory list");

FtpListItem[] list = ftpClient.GetListing("");

Console.WriteLine ("Showing result...");



foreach (FtpListItem ftpListItem in list) {

Console.WriteLine ("ftpListItem: " + ftpListItem.Name);

}

} catch (Exception e) {

Console.WriteLine("Exception: " + e);

}



Console.WriteLine("Done!");

Not sure if it is relevant but Im getting this error in monodevelop while running code on an iPad simulator.

Coordinator
Aug 17, 2012 at 12:47 PM

Yes, it's an issue in mono that I'm aware of. In mono when calling socket.Shutdown() and the remote host closes the socket first it triggers an exception. I'll push an update shortly to address this issue.

Coordinator
Aug 17, 2012 at 1:09 PM

I just pushed up a new revision of the 2012.08.08 branch which I tested with mono develop to make sure the problem is gone. You can get the source code through the source page (make sure you select the 2012.08.08 revision) or if you have hg or TortoiseHG installed  you can execute the following command:

hg clone -u 2012.08.08 https://hg01.codeplex.com/netftp