0

I need the expert help. I have written the C# console base application. In which I have to upload the zip file to FTPS server. Every time I am getting the connection refuse error. But when I connect by the FileZilla its connected and working fine.

I am using FTP Protocol and Encryption type is "Required Explicit FTP over TLS" logon type normal (see the below screen shots).

The exception message as below : "Connection failed.\r\nTLS connect: error in error\r\nCan't establish TLS connection\r\nDisconnected from server\r\nConnection failed"

Please provide any sample code or help me to correct this code.

My sample C# sample code as below :

using System;
using System.Collections.Generic;
using System.IO; 
using WinSCP;

namespace FTPS
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                SessionOptions sessionOptions = new SessionOptions
                {
                    Protocol = Protocol.Ftp,
                    HostName = "CIR-SVN34",
                    UserName = "buildmachine",
                    Password = "Password",
                    FtpSecure = FtpSecure.Implicit,
                    PortNumber = 990
                };

                using (Session session = new Session())
                {
                    // Connect
                    session.Open(sessionOptions);
                    // Upload files
                    TransferOptions transferOptions = new TransferOptions();
                    transferOptions.TransferMode = TransferMode.Binary;

                    TransferOperationResult transferResult;
                    transferResult =
                        session.PutFiles(@"C:\BuildProcess\Testing.zip", @"/Apps-Panel Dev Daily Build/", false, transferOptions);

                    // Throw on any error
                    transferResult.Check();
                    // Print results
                    foreach (TransferEventArgs transfer in transferResult.Transfers)
                    {
                        Console.WriteLine("Upload of {0} succeeded", transfer.FileName);
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
        }
    }
}

Working only with FileZilla client

enter image description here

enter image description here

skt
  • 449
  • 14
  • 32

1 Answers1

0

If your FileZilla configuration is working, then your server is strangely configured. It listens on implicit TLS port 990 for explicit TLS connection.

This should work:

FtpSecure = FtpSecure.Explicit,
PortNumber = 990,

Explicit TLS normally works on the standard FTP port 21.

Martin Prikryl
  • 188,800
  • 56
  • 490
  • 992