Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.3k views
in .NET FTP by (160 points)
Hi:

I instantiate a connection with New SecureFTPConnection with edtFTPnetPRO 4.0.3.0.
I got the exception occasionally when I try to close the connection.
In my finally block of .Net VB2.0 code, I have this
Finally
If ftpConnection.IsConnected = True Then ftpConnection.Close()
End Try

Sometimes it gives me the following exception:

System.Net.Sockets.SocketException: An existing connection was forcibly closed by the remote host
at System.Net.Sockets.Socket.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
at d0.a(Byte[] A_0, Int32 A_1, Int32 A_2)
at g4.a(az A_0, gv A_1)
at he.a(Byte[] A_0)
at fv.b(Byte[] A_0)
at fv.a()
at ad.a()
at EnterpriseDT.Net.Ftp.Ssh.SSHFTPClient.Quit()
at EnterpriseDT.Net.Ftp.FTPConnection.Close(Boolean abruptClose)
at EnterpriseDT.Net.Ftp.ExFTPConnection.Close(Boolean abruptClose)
at EnterpriseDT.Net.Ftp.FTPConnection.Close()
at Service.FtpDownload()

First question:
Can any support help me to take a look for what is wrong in the code or is the connection issue between the web sever and ftp server?

More information:
Before connection the setup is the following:
1.ftpConnection.LicenseOwner = ****
2.ftpConnection.LicenseKey = ****
3.ftpConnection.ServerAddress = ****
4.ftpConnection.ServerPort = 22
5.ftpConnection.UserName = ****
6.ftpConnection.Password = ****
7.ftpConnection.Protocol = FileTransferProtocol.SFTP
8.ftpConnection.ServerValidation = SecureFTPServerValidationType.None
9.ftpConnection.Connect()

After I have the connection via SecureFTPConnection.
1.ftpConnection.ChangeWorkingDirectory(****)
2.ftpConnection.GetFiles()
3.ftpConnection.DownloadFile(****)
4.ftpConnection.RenameFile(****, ****)

Second question:
Can any support tell me the exception is from which line above?

1 Answer

0 votes
by (162k points)
It looks like your SFTP server is abruptly closing the connection rather than going through the proper close process that the client is requesting via Close().

There's no harm in your finally block to just catch exceptions thrown by Close() and ignore them or just log them for informational purposes.

Categories

...