ArxOne / FTP

Simple FTP client
MIT License
37 stars 15 forks source link

FTP fail to connect when using FtpS #11

Closed abraaocaldas closed 8 years ago

abraaocaldas commented 8 years ago

Hello, i'm having trouble with a FTPS server with TLS certificate.

I traced the code and it always fails when it try to set the TransferMode in SetTransferMode method, you send a command with "TYPE", but I always get this reply:

{"IO Exception while connecting to FTP server"}

futhermore, you always _transferMode as the value that you get from method

 private void SetTransferMode(FtpTransferMode value)
        {
            if (value != _transferMode)
            {
                Expect(SendCommand("TYPE", value.ToString()), 200);
                _transferMode = value;
            }
        }

Is that correct?

picrap commented 8 years ago

Could you give me something more explicit, such as a sample?

abraaocaldas commented 8 years ago

Here is the code I'm using, it's pretty simple:

 using (var ftpClient = new FtpClient(FtpProtocol.FtpS, "10.0.0.1", 21, new NetworkCredential("myusername", "mypassword")))
            {
                using (var ftpSession = ftpClient.Session())
                {

                    var list = ftpClient.List("/");
                }
            }

So, then I get this exception on ftpClient.List method:

{"IO Exception while connecting to FTP server"}

The stackTrace:

at ArxOne.Ftp.FtpSession.Process[TResult](Func1 func, String commandDescription, String requestCommand, String[] requestParameters) in d:\Dev\FTP\ArxOne.Ftp\FtpSession.cs:line 203 at ArxOne.Ftp.FtpSession.Connect(TimeSpan connectTimeout, TimeSpan readWriteTimeout) in d:\Dev\FTP\ArxOne.Ftp\FtpSession.cs:line 214 at ArxOne.Ftp.FtpSession.get_ProtocolStream() in d:\Dev\FTP\ArxOne.Ftp\FtpSession.cs:line 79 at ArxOne.Ftp.FtpSession.SendCommand(String command, String[] parameters) in d:\Dev\FTP\ArxOne.Ftp\FtpSession.cs:line 412 at ArxOne.Ftp.FtpSession.SetTransferMode(FtpTransferMode value) in d:\Dev\FTP\ArxOne.Ftp\FtpSession.cs:line 681 at ArxOne.Ftp.FtpSession.OpenDataStream(Boolean passive, TimeSpan connectTimeout, TimeSpan readWriteTimeout, FtpTransferMode mode) in d:\Dev\FTP\ArxOne.Ftp\FtpSession.cs:line 585 at ArxOne.Ftp.FtpClientCore.OpenDataStream(FtpSessionHandle handle, FtpTransferMode mode) in d:\Dev\FTP\ArxOne.Ftp\FtpClientCore.cs:line 483 at ArxOne.Ftp.FtpClient.ProcessList(FtpSessionHandle handle, FtpPath path) in d:\Dev\FTP\ArxOne.Ftp\FtpClient.cs:line 176 at ArxOne.Ftp.FtpClient.<>c__DisplayClassb.<List>b__a(FtpSessionHandle handle) in d:\Dev\FTP\ArxOne.Ftp\FtpClient.cs:line 164 at ArxOne.Ftp.FtpClient.Process[TResult](Func2 action) in d:\Dev\FTP\ArxOne.Ftp\FtpClient.cs:line 153 at ArxOne.Ftp.FtpClient.List(FtpPath path) in d:\Dev\FTP\ArxOne.Ftp\FtpClient.cs:line 164 at TestApp2.Program.Main() in c:\Users\abraao.c\Documents\Visual Studio 2013\Projects\TestApp2\TestApp2\Program.cs:line 21 at System.AppDomain._nExecuteAssembly(RuntimeAssembly assembly, String[] args) at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args) at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly() at System.Threading.ThreadHelper.ThreadStart_Context(Object state) at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx) at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state) at System.Threading.ThreadHelper.ThreadStart()

picrap commented 8 years ago

Just to be sure: is your ftp server configured for FTPS? I'm confused, because usually FTPS uses another port that 21 (I think FTP servers use port 990).

abraaocaldas commented 8 years ago

Yep, unfortunately the server is not mine, but I'm sure it uses FTPS because it asks for TLS certificate when you first connect with Filezilla.

picrap commented 8 years ago

Confirmed. This is a bug. I'll try to release a fix tomorrow.

picrap commented 8 years ago

This is fixed in version 1.4 :joy: