Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.5k views
in .NET FTP by (200 points)
I was looking in the user manual and it states...

Secure Transfers are enabled through the Security properties. At a minimum, the Protocol should be set to SFTP, FTPSExplicit or FTPSImplicit representing the SSH File Transfer Protocol, explicit FTP over SSL, and implicit FTP over SSL, respectively. The issue of Server Validation must also be addressed.


We have an app that sets the connection property as:

Private ftpConnection As New EnterpriseDT.Net.Ftp.SecureFTPConnection


And we use config files to customize jobs for various clients so that we can use the singular app. Our config is setting the protocol to FTP as the FTP site is not secure...

What implications, if any, are we facing?

Background: our FTP logs are saying that it needs to be connected before uploading files... Excerpt below:

10:08:08 AM:ERROR -Source: edtFTPnetPRO
10:08:08 AM:ERROR -Trace:    at EnterpriseDT.Net.Ftp.FTPClient.a(Boolean A_0)
   at EnterpriseDT.Net.Ftp.FTPClient.ValidateTransferOnError()
   at EnterpriseDT.Net.Ftp.FTPClient.Put(String localPath, String remoteFile, Boolean append)
   at EnterpriseDT.Net.Ftp.FTPConnection.UploadFile(String localPath, String remoteFile, Boolean append)
   at EnterpriseDT.Net.Ftp.FTPConnection.UploadFile(String localPath, String remoteFile)
   at FTPFileTool.FtpFileTool.uploadFile(String fileName) in ...\FtpFileTool.vb:line 1256
   at FTPFileTool.FtpFileTool.uploadFileNames() in ...\FtpFileTool.vb:line 1059
   at FTPFileTool.FtpFileTool.processRequest() in ...\FtpFileTool.vb:line 499
10:08:08 AM:ERROR -Message: 1 - The FTP client has not yet connected to the server.  The requested action cannot be performed until after a connection has been established.
<br>
<br>EnterpriseDT.Net.Ftp.FTPException: The FTP client has not yet connected to the server.  The requested action cannot be performed until after a connection has been established.
   at EnterpriseDT.Net.Ftp.FTPClient.a(Boolean A_0)
   at EnterpriseDT.Net.Ftp.FTPClient.ValidateTransferOnError()
   at EnterpriseDT.Net.Ftp.FTPClient.Put(String localPath, String remoteFile, Boolean append)
   at EnterpriseDT.Net.Ftp.FTPConnection.UploadFile(String localPath, String remoteFile, Boolean append)
   at EnterpriseDT.Net.Ftp.FTPConnection.UploadFile(String localPath, String remoteFile)
   at FTPFileTool.FtpFileTool.uploadFile(String fileName) in ...\FtpFileTool.vb:line 1256
   at FTPFileTool.FtpFileTool.uploadFileNames() in ...\FtpFileTool.vb:line 1059
   at FTPFileTool.FtpFileTool.processRequest() in ...\FtpFileTool.vb:line 499
10:08:08 AM:ERROR -
An Error Occured During Processing!
10:08:08 AM:ERROR -Source: edtFTPnetPRO
10:08:08 AM:ERROR -Trace:    at EnterpriseDT.Net.Ftp.FTPClient.a(Boolean A_0)
   at EnterpriseDT.Net.Ftp.FTPClient.Quit()
   at EnterpriseDT.Net.Ftp.Ssl.SSLFTPClient.Quit()
   at EnterpriseDT.Net.Ftp.FTPConnection.Close(Boolean abruptClose)
   at EnterpriseDT.Net.Ftp.ExFTPConnection.Close(Boolean abruptClose)
   at EnterpriseDT.Net.Ftp.FTPConnection.Close()
   at FTPFileTool.FtpFileTool.ftpDisconnect() in ...\FtpFileTool.vb:line 1431
   at FTPFileTool.FtpFileTool.processRequest() in ...\FtpFileTool.vb:line 525
   at FTPFileTool.FtpFileTool.Main(String[] cmdArgs) in ...\FtpFileTool.vb:line 142
10:08:08 AM:ERROR -Message: 1 - The FTP client has not yet connected to the server.  The requested action cannot be performed until after a connection has been established.
<br>
<br>EnterpriseDT.Net.Ftp.FTPException: The FTP client has not yet connected to the server.  The requested action cannot be performed until after a connection has been established.
   at EnterpriseDT.Net.Ftp.FTPClient.a(Boolean A_0)
   at EnterpriseDT.Net.Ftp.FTPClient.Quit()
   at EnterpriseDT.Net.Ftp.Ssl.SSLFTPClient.Quit()
   at EnterpriseDT.Net.Ftp.FTPConnection.Close(Boolean abruptClose)
   at EnterpriseDT.Net.Ftp.ExFTPConnection.Close(Boolean abruptClose)
   at EnterpriseDT.Net.Ftp.FTPConnection.Close()
   at FTPFileTool.FtpFileTool.ftpDisconnect() in ...\FtpFileTool.vb:line 1431
   at FTPFileTool.FtpFileTool.processRequest() in ...\FtpFileTool.vb:line 525
   at FTPFileTool.FtpFileTool.Main(String[] cmdArgs) in ...\FtpFileTool.vb:line 142

5 Answers

0 votes
by (162k points)
If you use the FTP protocol, the transfer is not secure - passwords and data are sent in clear text.

As to the error you are experiencing, we can't really tell what is happening without a log file at the Debug level.
0 votes
by (200 points)
Here are the logs received:
DEBUG [SFTPMessageStore] 7 Aug 2013 06:49:18.213 : Set timeout=300000
INFO [LicenseProperties] 7 Aug 2013 06:49:18.229 : Licence expiry date: 12/31/9999
INFO [LicenseProperties] 7 Aug 2013 06:49:18.229 : Production license
DEBUG [FTPConnection] 7 Aug 2013 06:49:18.229 : Set LocalDirectory='...\NightlyProcessReps_IDI'
INFO [LicenseProperties] 7 Aug 2013 06:49:18.229 : Licence expiry date: 12/31/9999
INFO [LicenseProperties] 7 Aug 2013 06:49:18.229 : Production license
DEBUG [SSLFTPClient] 7 Aug 2013 06:49:18.229 : Connecting to xxx.xxxx.xxx:21
DEBUG [HostNameResolver] 7 Aug 2013 06:49:18.369 : xxx.xxxx.xxx resolved to 999.999.999.999
DEBUG [SSLFTPControlSocket] 7 Aug 2013 06:49:18.369 : waitOnShutdownSSL=True
DEBUG [ExFTPControlSocket] 7 Aug 2013 06:49:18.385 : Connecting directly to ftp-server 999.999.999.999:21
DEBUG [FTPControlSocket] 7 Aug 2013 06:49:18.448 : Setting socket timeout=300000
DEBUG [SecureSocket] 7 Aug 2013 06:49:18.448 : Set timeout=300000
DEBUG [SecureSocket] 7 Aug 2013 06:49:18.448 : Set timeout=300000
DEBUG [FTPControlSocket] 7 Aug 2013 06:49:18.448 : Command encoding=System.Text.ASCIIEncoding
DEBUG [ExFTPControlSocket] 7 Aug 2013 06:49:18.448 : Created control-socket: SocksContext=, ProxySettings=NoProxy, RemoteHost=999.999.999.999, controlPort=21, timeout=300000
DEBUG [FTPControlSocket] 7 Aug 2013 06:49:18.448 : StrictReturnCodes=False
DEBUG [FTPControlSocket] 7 Aug 2013 06:49:18.526 : 220 Welcome to xxx.xxxx.xxx
DEBUG [SecureFTPConnection] 7 Aug 2013 06:49:18.526 : Changing local working directory to ...\NightlyProcessReps_IDI
DEBUG [FTPControlSocket] 7 Aug 2013 06:49:18.526 : ---> USER ftp_XXXXXXXXX
DEBUG [FTPControlSocket] 7 Aug 2013 06:49:18.588 : 331 Password required for ftp_XXXXXXXXX
DEBUG [FTPControlSocket] 7 Aug 2013 06:49:18.588 : ---> PASS ********
DEBUG [FTPControlSocket] 7 Aug 2013 06:49:18.666 : 230 Logged on
DEBUG [FTPConnection] 7 Aug 2013 06:49:18.666 : Successfully logged in
DEBUG [EnterpriseDT.Net.Ftp.ExFTPConnection] 7 Aug 2013 06:49:18.666 : Starting KeepAlive thread with period 30s
DEBUG [FTPControlSocket] 7 Aug 2013 06:49:18.666 : ---> TYPE A
DEBUG [FTPControlSocket] 7 Aug 2013 06:49:18.745 : 200 Type set to A
DEBUG [FTPControlSocket] 7 Aug 2013 06:49:18.745 : ---> PWD
DEBUG [FTPControlSocket] 7 Aug 2013 06:49:18.807 : 257 "/" is current directory.
DEBUG [FTPConnection] 7 Aug 2013 06:49:19.807 : Combining absolute path '...\NightlyProcessReps_IDI' with relative path '...\array.dat'
DEBUG [SSLFTPControlSocket] 7 Aug 2013 06:49:19.807 : Creating active data socket on port 0
DEBUG [ExFTPControlSocket] 7 Aug 2013 06:49:19.807 : Binding 99.99.99.99
DEBUG [FTPControlSocket] 7 Aug 2013 06:49:19.807 : ---> PORT 99,99,99,99,14,26
ERROR [SecureNetworkStream] 7 Aug 2013 06:49:19.807 : Socket.Receive() failed : System.Net.Sockets.SocketException: 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 et.a(Byte[] A_0, Int32 A_1, Int32 A_2, SocketFlags A_3)
   at ev.a(Byte[] A_0, Int32 A_1, Int32 A_2, SocketFlags A_3)
   at d.b(Byte[] A_0, Int32 A_1, Int32 A_2)
ERROR [FTPControlSocket] 7 Aug 2013 06:49:19.823 : Exception in SendCommand : System.IO.IOException: An I/O exception occurred.
System.IO.IOException: An I/O exception occurred.
   at d.b(Byte[] A_0, Int32 A_1, Int32 A_2)
   at System.IO.StreamReader.ReadBuffer()
   at System.IO.StreamReader.ReadLine()
   at EnterpriseDT.Net.Ftp.FTPControlSocket.ReadReply()
   at EnterpriseDT.Net.Ftp.FTPControlSocket.SendCommand(String command)
CAUSED BY:
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 et.a(Byte[] A_0, Int32 A_1, Int32 A_2, SocketFlags A_3)
   at ev.a(Byte[] A_0, Int32 A_1, Int32 A_2, SocketFlags A_3)
   at d.b(Byte[] A_0, Int32 A_1, Int32 A_2)
ERROR [EnterpriseDT.Net.Ftp.ExFTPConnection] 7 Aug 2013 06:49:19.823 : Command error : System.IO.IOException: An I/O exception occurred.
System.IO.IOException: An I/O exception occurred.
   at d.b(Byte[] A_0, Int32 A_1, Int32 A_2)
   at System.IO.StreamReader.ReadBuffer()
   at System.IO.StreamReader.ReadLine()
   at EnterpriseDT.Net.Ftp.FTPControlSocket.ReadReply()
   at EnterpriseDT.Net.Ftp.FTPControlSocket.SendCommand(String command)
CAUSED BY:
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 et.a(Byte[] A_0, Int32 A_1, Int32 A_2, SocketFlags A_3)
   at ev.a(Byte[] A_0, Int32 A_1, Int32 A_2, SocketFlags A_3)
   at d.b(Byte[] A_0, Int32 A_1, Int32 A_2)
DEBUG [AsyncProcessor] 7 Aug 2013 06:49:19.823 : Stopping FTP task processor.
DEBUG [AsyncProcessor] 7 Aug 2013 06:49:19.823 : FTP task processor stopped.
ERROR [ExFTPControlSocket] 7 Aug 2013 06:49:19.823 : Failed to create listening socket : System.IO.IOException: An I/O exception occurred.
System.IO.IOException: An I/O exception occurred.
   at d.b(Byte[] A_0, Int32 A_1, Int32 A_2)
   at System.IO.StreamReader.ReadBuffer()
   at System.IO.StreamReader.ReadLine()
   at EnterpriseDT.Net.Ftp.FTPControlSocket.ReadReply()
   at EnterpriseDT.Net.Ftp.FTPControlSocket.SendCommand(String command)
   at EnterpriseDT.Net.Ftp.FTPControlSocket.a(IPEndPoint A_0)
   at aw.a(Int32 A_0, BaseSocket A_1)
CAUSED BY:
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 et.a(Byte[] A_0, Int32 A_1, Int32 A_2, SocketFlags A_3)
   at ev.a(Byte[] A_0, Int32 A_1, Int32 A_2, SocketFlags A_3)
   at d.b(Byte[] A_0, Int32 A_1, Int32 A_2)
DEBUG [FTPClient] 7 Aug 2013 06:49:19.823 : Closing source stream
ERROR [FTPClient] 7 Aug 2013 06:49:19.823 : Caught exception : System.IO.IOException: An I/O exception occurred.
System.IO.IOException: An I/O exception occurred.
   at d.b(Byte[] A_0, Int32 A_1, Int32 A_2)
   at System.IO.StreamReader.ReadBuffer()
   at System.IO.StreamReader.ReadLine()
   at EnterpriseDT.Net.Ftp.FTPControlSocket.ReadReply()
   at EnterpriseDT.Net.Ftp.FTPControlSocket.SendCommand(String command)
   at EnterpriseDT.Net.Ftp.FTPControlSocket.a(IPEndPoint A_0)
   at aw.a(Int32 A_0, BaseSocket A_1)
   at an.a(Int32 A_0)
   at EnterpriseDT.Net.Ftp.FTPControlSocket.CreateDataSocketActive()
   
0 votes
by (162k points)
It looks like the server is unable to connect back to the client on the port number the client is listening on. It might be worth using passive mode rather active mode.
0 votes
by (200 points)
At first glance it looks like Passive Mode worked, but then threw an error.

DEBUG [SFTPMessageStore] 8 Aug 2013 09:10:49.878 : Set timeout=300000
INFO [LicenseProperties] 8 Aug 2013 09:10:49.878 : Licence expiry date: 12/31/9999
INFO [LicenseProperties] 8 Aug 2013 09:10:49.878 : Production license
DEBUG [FTPConnection] 8 Aug 2013 09:10:49.878 : Set LocalDirectory='...\NightlyProcessReps_IDI'
INFO [LicenseProperties] 8 Aug 2013 09:10:49.878 : Licence expiry date: 12/31/9999
INFO [LicenseProperties] 8 Aug 2013 09:10:49.878 : Production license
DEBUG [SSLFTPClient] 8 Aug 2013 09:10:49.878 : Connecting to xxx.xxxx.xxx:21
DEBUG [HostNameResolver] 8 Aug 2013 09:10:50.065 : xxx.xxxx.xxx resolved to 99.99.99.99
DEBUG [SSLFTPControlSocket] 8 Aug 2013 09:10:50.065 : waitOnShutdownSSL=True
DEBUG [ExFTPControlSocket] 8 Aug 2013 09:10:50.065 : Connecting directly to ftp-server 99.99.99.99:21
DEBUG [FTPControlSocket] 8 Aug 2013 09:10:50.128 : Setting socket timeout=300000
DEBUG [SecureSocket] 8 Aug 2013 09:10:50.128 : Set timeout=300000
DEBUG [SecureSocket] 8 Aug 2013 09:10:50.128 : Set timeout=300000
DEBUG [FTPControlSocket] 8 Aug 2013 09:10:50.128 : Command encoding=System.Text.ASCIIEncoding
DEBUG [ExFTPControlSocket] 8 Aug 2013 09:10:50.128 : Created control-socket: SocksContext=, ProxySettings=NoProxy, RemoteHost=99.99.99.99, controlPort=21, timeout=300000
DEBUG [FTPControlSocket] 8 Aug 2013 09:10:50.128 : StrictReturnCodes=False
DEBUG [FTPControlSocket] 8 Aug 2013 09:10:50.190 : 220 Welcome to xxx.xxxx.xxx
DEBUG [SecureFTPConnection] 8 Aug 2013 09:10:50.190 : Changing local working directory to ...\NightlyProcessReps_IDI
DEBUG [FTPControlSocket] 8 Aug 2013 09:10:50.190 : ---> USER ftp_XXXXXXXXX
DEBUG [FTPControlSocket] 8 Aug 2013 09:10:50.253 : 331 Password required for ftp_XXXXXXXXX
DEBUG [FTPControlSocket] 8 Aug 2013 09:10:50.253 : ---> PASS ********
DEBUG [FTPControlSocket] 8 Aug 2013 09:10:50.315 : 230 Logged on
DEBUG [FTPConnection] 8 Aug 2013 09:10:50.315 : Successfully logged in
DEBUG [EnterpriseDT.Net.Ftp.ExFTPConnection] 8 Aug 2013 09:10:50.315 : Starting KeepAlive thread with period 30s
DEBUG [FTPControlSocket] 8 Aug 2013 09:10:50.315 : ---> TYPE A
DEBUG [FTPControlSocket] 8 Aug 2013 09:10:50.378 : 200 Type set to A
DEBUG [FTPControlSocket] 8 Aug 2013 09:10:50.378 : ---> PWD
DEBUG [FTPControlSocket] 8 Aug 2013 09:10:50.440 : 257 "/" is current directory.
DEBUG [FTPConnection] 8 Aug 2013 09:10:51.440 : Combining absolute path '...\NightlyProcessReps_IDI' with relative path '...\IDINightlyRepFile\array.dat'
DEBUG [FTPControlSocket] 8 Aug 2013 09:10:51.440 : ---> PASV
DEBUG [FTPControlSocket] 8 Aug 2013 09:10:51.503 : 227 Entering Passive Mode (99,99,99,99,213,93)
DEBUG [FTPControlSocket] 8 Aug 2013 09:10:51.503 : Server supplied address=99.99.99.99
DEBUG [FTPControlSocket] 8 Aug 2013 09:10:51.503 : Server supplied port=54621
DEBUG [FTPControlSocket] 8 Aug 2013 09:10:51.503 : Substituting server supplied IP (99.99.99.99) with remote host IP (99.99.99.99)
DEBUG [SecureSocket] 8 Aug 2013 09:10:51.503 : Set timeout=300000
DEBUG [SecureSocket] 8 Aug 2013 09:10:51.503 : Set timeout=300000
DEBUG [ExFTPControlSocket] 8 Aug 2013 09:10:51.503 : Connecting directly to ftp-server 99.99.99.99:54621
DEBUG [ExFTPPassiveDataSocket] 8 Aug 2013 09:10:51.565 : Created passive data-socket: ProxyConnector=
DEBUG [SSLFTPPassiveDataSocket] 8 Aug 2013 09:10:51.565 : Created passive data-socket: Protocol=None, CompatibilityFlags=Standard, UseSSLClosure=True, WaitOnClose=True
DEBUG [SecureSocket] 8 Aug 2013 09:10:51.565 : Set timeout=300000
DEBUG [SecureSocket] 8 Aug 2013 09:10:51.565 : Set timeout=300000
DEBUG [FTPControlSocket] 8 Aug 2013 09:10:51.565 : ---> STOR array.dat
DEBUG [FTPControlSocket] 8 Aug 2013 09:10:51.628 : 150 Connection accepted
ERROR [SecureNetworkStream] 8 Aug 2013 09:15:51.977 : Socket.Send() failed : System.Net.Sockets.SocketException: 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.Send(Byte[] buffer, Int32 offset, Int32 size, SocketFlags socketFlags)
   at et.b(Byte[] A_0, Int32 A_1, Int32 A_2, SocketFlags A_3)
   at ev.b(Byte[] A_0, Int32 A_1, Int32 A_2, SocketFlags A_3)
   at d.a(Byte[] A_0, Int32 A_1, Int32 A_2)
DEBUG [FTPClient] 8 Aug 2013 09:15:51.977 : Closing source stream
DEBUG [SSLFTPPassiveDataSocket] 8 Aug 2013 09:15:51.977 : Attempt to close unconnected passive data-channel.
ERROR [FTPClient] 8 Aug 2013 09:15:51.977 : Caught exception : System.IO.IOException: An I/O exception occurred.
System.IO.IOException: An I/O exception occurred.
   at d.a(Byte[] A_0, Int32 A_1, Int32 A_2)
   at System.IO.StreamWriter.Flush(Boolean flushStream, Boolean flushEncoder)
   at System.IO.StreamWriter.Write(String value)
   at EnterpriseDT.Net.Ftp.FTPClient.b(Stream A_0, String A_1, Boolean A_2, Boolean A_3)
CAUSED BY:
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 et.b(Byte[] A_0, Int32 A_1, Int32 A_2, SocketFlags A_3)
   at ev.b(Byte[] A_0, Int32 A_1, Int32 A_2, SocketFlags A_3)
   at d.a(Byte[] A_0, Int32 A_1, Int32 A_2)
ERROR [FTPClient] 8 Aug 2013 09:15:51.993 : IOException in Put(string,string,bool) : System.IO.IOException: An I/O exception occurred.
System.IO.IOException: An I/O exception occurred.
   at EnterpriseDT.Net.Ftp.FTPClient.b(Stream A_0, String A_1, Boolean A_2, Boolean A_3)
   at EnterpriseDT.Net.Ftp.FTPClient.b(String A_0, String A_1, Boolean A_2)
   at EnterpriseDT.Net.Ftp.FTPClient.Put(String localPath, String remoteFile, Boolean append)
CAUSED BY:
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 et.b(Byte[] A_0, Int32 A_1, Int32 A_2, SocketFlags A_3)
   at ev.b(Byte[] A_0, Int32 A_1, Int32 A_2, SocketFlags A_3)
   at d.a(Byte[] A_0, Int32 A_1, Int32 A_2)
DEBUG [FTPControlSocket] 8 Aug 2013 09:15:51.993 : Setting socket timeout=500
DEBUG [SecureSocket] 8 Aug 2013 09:15:51.993 : Set timeout=500
DEBUG [SecureSocket] 8 Aug 2013 09:15:51.993 : Set timeout=500
ERROR [SecureNetworkStream] 8 Aug 2013 09:15:51.993 : Socket.Receive() failed : System.Net.Sockets.SocketException: 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 et.a(Byte[] A_0, Int32 A_1, Int32 A_2, SocketFlags A_3)
   at ev.a(Byte[] A_0, Int32 A_1, Int32 A_2, SocketFlags A_3)
   at d.b(Byte[] A_0, Int32 A_1, Int32 A_2)
DEBUG [FTPControlSocket&#
0 votes
by (162k points)
It looks then like a firewall is terminating the connection. Check the server and client firewalls.

Categories

...