+1 vote
by (160 points)

We're having problems connecting to a particular server with the FTP.NET Winform Sample Client (WinFormClient.exe). The FTP server we're trying to connect to is running Windows Server 2008 R2 (x64) with IIS7.5.

Here's the log file output:

18:57:32.798 Info Response: 220 Microsoft FTP Service
18:57:32.811 Info Command: USER JUser
18:57:32.850 Info Response: 331 Password required for JUser.
18:57:32.855 Info Command: PASS *************
18:57:32.884 Info Response: 230 User logged in.
18:57:32.890 Info Command: FEAT
18:57:32.911 Info Response: 211-Extended features supported:
18:57:33.127 Info Response:  LANG EN*
18:57:33.131 Info Response:  UTF8
18:57:33.136 Info Response:  AUTH TLS;TLS-C;SSL;TLS-P;
18:57:33.142 Info Response:  PBSZ
18:57:33.147 Info Response:  PROT C;P;
18:57:33.152 Info Response:  CCC
18:57:33.159 Info Response:  HOST
18:57:33.164 Info Response:  SIZE
18:57:33.167 Info Response:  MDTM
18:57:33.174 Info Response:  REST STREAM
18:57:33.178 Info Response: 211 END
18:57:33.183 Info Command: SITE
18:57:33.204 Info Response: 214-The following SITE commands are recognized (* ==>'s unimplemented).
18:57:57.376 Error Info: Rebex.Net.FtpException: An existing connection was forcibly closed by the remote host. ---> System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
   at System.Net.Sockets.Socket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at Rebex.Net.ProxySocket.Receive(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at wWGvS.AgXIfM.BMJzdYZ(Byte[] , Int32 )
   at wWGvS.AgXIfM.BbLKfs(String& )
   at wWGvS.AgXIfM.KsZclZ()
   at Rebex.Net.Ftp.cgrDQE(Int32 )
   --- End of inner exception stack trace ---
   at Rebex.Net.Ftp.cgrDQE(Int32 )
   at Rebex.Net.Ftp.vEGVl()
   at Rebex.Net.Ftp.Login(String userName, String password)

We're able to connect fine using other FTP software (such as FileZilla), so it appears to be a problem with the Rebex library...?

Thanks for any help.

Applies to: Rebex FTP/SSL
by (134k points)
This looks like Rebex FTP got stuck while waiting for SITE command response. This has not been reported before - we are running our automated tests against MS FTP 7.5. Please locate the "_ftp = new Ftp();" line in the WinFormClient sample and add the following line below it: "_ftp.Options |= FtpOptions.DoNotDetectFeatures;" - does this make any difference? (Please post the log if it doesn't.)
by (134k points)
(In VB.NET, locate "_ftp = New Ftp" and add "_ftp.Options = _ftp.Options Or FtpOptions.DoNotDetectFeatures")
by (160 points)
It worked! Connects perfectly now! Thanks!
by (160 points)
(You should have posted it as an answer, so I could mark this question solved :)
by (134k points)
Thanks! I did not actually expect that this alone would help - I thought several more iterations would be needed first. But I will repost this as an answer now :-)

1 Answer

+1 vote
by (134k points)
Best answer

This looks like Rebex FTP got stuck while waiting for the SITE command response. Unlike FileZilla, we are using the SITE command to detect MS IIS FTP 7 and 7.5, but it looks like this is not working.

To work around this issue, try disabling FTP server feature detection. Locate the following line in the WinFormClient sample:

_ftp = new Ftp();

And add the following line below it:

_ftp.Settings.DoNotDetectFeatures = true;


_ftp.Options |= FtpOptions.DoNotDetectFeatures;

for older versions of Rebex components where the Settings property is not present.

If this doesn't help, please let us know and post an updated log.

More information: The issue itself is unlikely to be caused by MS IIS FTP 7.5 or Rebex FTP alone - we routinely run our automated tests against this FTP server and never noticed such problems. A possible explanation is a FTP-aware firewall along the way that doesn't handle IIS FTP's SITE command response properly.

by (160 points)
Thanks again! -JP