I'm attempting to transfer a file via SFTP, but I consistantly reach an error: "The command socket was disconnected from the FTP server." at my EndConnect line. Below is some of my source. Has anyone happened upon a solution for this?
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Xceed.Ftp.Licenser.LicenseKey = System.Configuration.ConfigurationManager.AppSettings("componentLicense")
Dim iphost As IPHostEntry = Dns.Resolve("ServerName")
Dim sftpServerAddress = iphost.HostName.ToString
Dim sftpServerPort = "22"
Dim sftpUsername = "Domain/User"
Dim sftpPassword = "Password"
' Create an instance of an FTP Client
Dim FtpClient1 As Xceed.Ftp.AsyncFtpClient = New Xceed.Ftp.AsyncFtpClient()
AddHandler FtpClient1.CertificateReceived, AddressOf Certificate_received
' Connect and Login to the FTP Client
Dim result As IAsyncResult = FtpClient1.BeginConnect(sftpServerAddress, sftpServerPort, AuthenticationMethod.Tls, VerificationFlags.None, Nothing, Nothing, Nothing)
FtpClient1.EndConnect(result)
FtpClient1.Login(sftpUsername, sftpPassword)
FtpClient1.SendFile("C:\test\test1.txt")
FtpClient1.Disconnect()
RemoveHandler FtpClient1.CertificateReceived, AddressOf certificate_received
End Sub
Public Sub certificate_received(ByVal sender As Object, ByVal e As CertificateReceivedEventArgs)
e.Action = VerificationAction.Accept
End Sub