Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
5k views
in .NET FTP by (1.2k points)
When I am at work I don't have any problems making a connection, but when I am at home it makes about 5 connections and then the program throws an error stating the connection didn't respond in time. I know I'm not using asynchronous methods (because I created my own which calls the method below), but is there a way to make it wait until a connection is established without throwing the error?

        protected void download(String localPath, String[] remoteFile, int partNumber)
        {
            ExFTPConnection dConnection = new ExFTPConnection();
            dConnection.TransferNotifyInterval = 100000;
            
            dConnection.Downloading += new FTPFileTransferEventHandler(dConnection_Downloading);
            dConnection.BytesTransferred += new BytesTransferredHandler(dConnection_BytesTransferred);

            dConnection.LicenseOwner = "XXXXXX";
            dConnection.LicenseKey = "XXXXXXXXXXXXXXXXX";
            dConnection.ServerAddress = "xxxxxxxxxxxxx";
            dConnection.UserName = "xxxxxxxxxx";
            dConnection.Password = "";
            

            dConnection.Connect();

            FileStream outFile = new FileStream(Path.Combine(localPath, "Part" + partNumber + ".part"), FileMode.Append, FileAccess.Write);
            for (int j = 0; j < 10; j++)
            {
                int chunk = partNumber * 10 + j;
                byte[] buffer = dConnection.DownloadByteArray(remoteFile[chunk]);
                outFile.Write(buffer, 0, buffer.Length);

                lock (dthreads_used)
                {
                    d_threads_used++;

                }
                downloadBar.Invoke(new UpdateDownloadBarCallback(this.UpdateDownloadBar), new object[] { d_threads_used - 1 });

            }

            outFile.Close();
        }

7 Answers

0 votes
by (162k points)
Try setting a long timeout. If that doesn't work, post a logfile set to DEBUG level.
0 votes
by (1.2k points)
You do that by: dConnection.Timeout = whatever?
0 votes
by (51.6k points)
yes
0 votes
by (1.2k points)
I am still having the issue. It is really bothering me, because just a couple of days ago everything was working fine and now I can't even download a file. here is my stack trace:

DEBUG [ExFTPClient] 19 Jun 2008 21:33:58.375 : Connecting to virtualh2oftp.ica.umt.edu:21
DEBUG [HostNameResolver] 19 Jun 2008 21:33:58.375 : virtualh2oftp.ica.umt.edu resolved to 150.131.193.150
DEBUG [ExFTPControlSocket] 19 Jun 2008 21:33:58.375 : Connecting directly to ftp-server 150.131.193.150:21
DEBUG [FTPControlSocket] 19 Jun 2008 21:33:58.375 : Setting socket timeout=120000
DEBUG [FTPControlSocket] 19 Jun 2008 21:33:58.375 : Command encoding=System.Text.ASCIIEncoding
DEBUG [ExFTPControlSocket] 19 Jun 2008 21:33:58.375 : Created control-socket: SocksContext=, ProxySettings=NoProxy, RemoteHost=150.131.193.150, controlPort=21, timeout=120000
DEBUG [FTPControlSocket] 19 Jun 2008 21:33:58.375 : StrictReturnCodes=False
DEBUG [FTPControlSocket] 19 Jun 2008 21:33:58.515 : 220-FileZilla Server version 0.9.24 beta
DEBUG [FTPControlSocket] 19 Jun 2008 21:33:58.578 : 220-written by Tim Kosse (Tim.Kosse@gmx.de)
DEBUG [FTPControlSocket] 19 Jun 2008 21:33:58.578 : 220 Please visit http://sourceforge.net/projects/filezilla/
DEBUG [FTPControlSocket] 19 Jun 2008 21:33:58.578 : ---> USER virtual.user
DEBUG [EnterpriseDT.Net.Ftp.ExFTPConnection] 19 Jun 2008 21:33:58.578 : Starting KeepAlive thread with period 30s
DEBUG [FTPControlSocket] 19 Jun 2008 21:33:58.640 : 331 Password required for virtual.user
DEBUG [FTPControlSocket] 19 Jun 2008 21:33:58.640 : ---> PASS ********
DEBUG [FTPControlSocket] 19 Jun 2008 21:33:58.687 : 230 Logged on
DEBUG [FTPConnection] 19 Jun 2008 21:33:58.687 : Successfully logged in
DEBUG [FTPControlSocket] 19 Jun 2008 21:33:58.687 : ---> TYPE I
DEBUG [FTPControlSocket] 19 Jun 2008 21:33:58.750 : 200 Type set to I
DEBUG [FTPControlSocket] 19 Jun 2008 21:33:58.750 : ---> PWD
DEBUG [FTPControlSocket] 19 Jun 2008 21:33:58.812 : 257 "/" is current directory.
DEBUG [FTPControlSocket] 19 Jun 2008 21:33:58.812 : ---> CWD /
DEBUG [FTPControlSocket] 19 Jun 2008 21:33:58.875 : 250 CWD successful. "/" is current directory.
DEBUG [FTPControlSocket] 19 Jun 2008 21:33:58.875 : ---> PWD
DEBUG [FTPControlSocket] 19 Jun 2008 21:33:58.937 : 257 "/" is current directory.
DEBUG [FTPConnection] 19 Jun 2008 21:33:59.968 : Set LocalDirectory='C:\Documents'
ALL [FTPConnection] 19 Jun 2008 21:33:59.968 : Invoking delegate EnterpriseDT.Net.Ftp.FTPDirectoryEventHandler -> EnterpriseDT.Net.Ftp.Forms.FTPLocalFileList.ftp_LocalDirectoryChanged
ALL [FTPConnection] 19 Jun 2008 21:33:59.968 : Have GUI control
ALL [FTPConnection] 19 Jun 2008 21:33:59.968 : GUI control invocation not required
ALL [FTPConnection] 19 Jun 2008 21:33:59.968 : Invoking delegate dynamically
ALL [FTPConnection] 19 Jun 2008 21:33:59.968 : Dynamic delegate invocation complete
DEBUG [EnterpriseDT.Net.Ftp.ExFTPConnection] 19 Jun 2008 21:34:18.281 : KeepAlive - testing connection
DEBUG [EnterpriseDT.Net.Ftp.ExFTPConnection] 19 Jun 2008 21:34:18.281 : Testing connection
DEBUG [FTPControlSocket] 19 Jun 2008 21:34:18.281 : ---> PWD
DEBUG [FTPControlSocket] 19 Jun 2008 21:34:18.343 : 257 "/" is current directory.
DEBUG [EnterpriseDT.Net.Ftp.ExFTPConnection] 19 Jun 2008 21:34:29.078 : KeepAlive - testing connection
DEBUG [EnterpriseDT.Net.Ftp.ExFTPConnection] 19 Jun 2008 21:34:29.078 : Testing connection
DEBUG [FTPControlSocket] 19 Jun 2008 21:34:29.078 : ---> PWD
DEBUG [FTPControlSocket] 19 Jun 2008 21:34:29.171 : 257 "/" is current directory.
DEBUG [EnterpriseDT.Net.Ftp.ExFTPConnection] 19 Jun 2008 21:34:48.843 : KeepAlive - testing connection
DEBUG [EnterpriseDT.Net.Ftp.ExFTPConnection] 19 Jun 2008 21:34:48.843 : Testing connection
DEBUG [FTPControlSocket] 19 Jun 2008 21:34:48.843 : ---> PWD
DEBUG [FTPControlSocket] 19 Jun 2008 21:34:48.921 : 257 "/" is current directory.
DEBUG [EnterpriseDT.Net.Ftp.ExFTPConnection] 19 Jun 2008 21:34:59.187 : KeepAlive - testing connection
DEBUG [EnterpriseDT.Net.Ftp.ExFTPConnection] 19 Jun 2008 21:34:59.187 : Testing connection
DEBUG [FTPControlSocket] 19 Jun 2008 21:34:59.187 : ---> PWD
DEBUG [FTPControlSocket] 19 Jun 2008 21:34:59.312 : 257 "/" is current directory.
DEBUG [EnterpriseDT.Net.Ftp.ExFTPConnection] 19 Jun 2008 21:35:18.937 : KeepAlive - testing connection
DEBUG [EnterpriseDT.Net.Ftp.ExFTPConnection] 19 Jun 2008 21:35:18.937 : Testing connection
DEBUG [FTPControlSocket] 19 Jun 2008 21:35:18.937 : ---> PWD
DEBUG [FTPControlSocket] 19 Jun 2008 21:35:19.000 : 257 "/" is current directory.
DEBUG [EnterpriseDT.Net.Ftp.ExFTPConnection] 19 Jun 2008 21:35:29.812 : KeepAlive - testing connection
DEBUG [EnterpriseDT.Net.Ftp.ExFTPConnection] 19 Jun 2008 21:35:29.812 : Testing connection
DEBUG [FTPControlSocket] 19 Jun 2008 21:35:29.812 : ---> PWD
DEBUG [FTPControlSocket] 19 Jun 2008 21:35:29.875 : 257 "/" is current directory.
Remote Path: /Storage/tempSAC ST SPT vs UCD.mp2aaron.heiner
C:\Downloads\Storage\tempSAC ST SPT vs UCD.mp2aaron.heiner
not_encoded
DEBUG [FTPConnection] 19 Jun 2008 21:35:36.390 : Listing directory '/Storage/tempSAC ST SPT vs UCD.mp2aaron.heiner'
DEBUG [FTPControlSocket] 19 Jun 2008 21:35:36.390 : ---> PASV
DEBUG [FTPControlSocket] 19 Jun 2008 21:35:36.484 : 227 Entering Passive Mode (150,131,193,150,5,85)
DEBUG [FTPControlSocket] 19 Jun 2008 21:35:36.484 : Server supplied address=150.131.193.150
DEBUG [FTPControlSocket] 19 Jun 2008 21:35:36.484 : Server supplied port=1365
DEBUG [FTPControlSocket] 19 Jun 2008 21:35:36.484 : Substituting server supplied IP (150.131.193.150) with remote host IP (150.131.193.150)
DEBUG [ExFTPControlSocket] 19 Jun 2008 21:35:36.484 : NewPassiveDataSocket(150.131.193.150,1365)
DEBUG [ExFTPControlSocket] 19 Jun 2008 21:35:36.484 : Connecting directly to ftp-server 150.131.193.150:1365
DEBUG [ExFTPPassiveDataSocket] 19 Jun 2008 21:35:36.531 : Created passive data-socket: ProxyConnector=
DEBUG [FTPControlSocket] 19 Jun 2008 21:35:36.531 : ---> NLST /Storage/tempSAC ST SPT vs UCD.mp2aaron.heiner
DEBUG [FTPControlSocket] 19 Jun 2008 21:35:36.609 : 150 Connection accepted
DEBUG [FTPClient] 19 Jun 2008 21:35:36.609 : Reading ASCII listing data
DEBUG [FTPClient] 19 Jun 2008 21:35:38.781 : -->/Storage/tempSAC ST SPT vs UCD.mp2aaron.heiner/SAC ST SPT vs UCD.mp2.0000.part
DEBUG [FTPClient] 19 Jun 2008 21:35:38.781 : -->/Storage/tempSAC ST SPT vs UCD.mp2aaron.heiner/SAC ST SPT vs UCD.mp2.0001.part
DEBUG [FTPControlSocket] 19 Jun 2008 21:35:41.015 : 226 Transfer OK
DEBUG [FTPClient] 19 Jun 2008 21:35:41.015 : Found 100 listing lines
DEBUG [FTPConnection] 19 Jun 2008 21:35:41.015 : Listed directory '/Storage/tempSAC ST SPT vs UCD.mp2aaron.heiner'
DEBUG [AsyncProcessor] 19 Jun 2008 21:35:41.015 : Stopping FTP task processor.
DEBUG [AsyncProcessor] 19 Jun 2008 21:35:41.015 : FTP task processor stopped.
DEBUG [FTPControlSocket] 19 Jun 2008 21:35:41.015 : ---> QUIT
DEBUG [FTPControlSocket] 19 Jun 2008 21:35:41.078 : 221 Goodbye
ERROR [FTPLocalFileList] 19 Jun 2008 21:35:41.218 : Object reference not set to an instance of an object. : System.NullReferenceException: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
0 votes
by (51.6k points)
Hi Aaron

I'm sorry but can you please e-mail the log to us at support? I tried to trim it coz it was so huge and accidentally removed the wrong part.

- Hans (EnterpriseDT)
0 votes
by (1.2k points)
I was able to get the above to work. I had to change a lot of code though. Now when I try and download a file I get this error:

C:\Documents\TomSmith_BenHeiner.mov
The thread 0x12a4 has exited with code 0 (0x0).
A first chance exception of type 'EnterpriseDT.Net.Ftp.FTPException' occurred in edtFTPnetPRO.dll
System.Transactions Critical: 0 : <TraceRecord xmlns="http://schemas.microsoft.com/2004/10/E2ETraceEvent/TraceRecord" Severity="Critical"><TraceIdentifier>http://msdn.microsoft.com/TraceCodes/System/ActivityTracing/2004/07/Reliability/Exception/Unhandled</TraceIdentifier><Description>Unhandled exception</Description><AppDomain>Virtual FTP Client.vshost.exe</AppDomain><Exception><ExceptionType>EnterpriseDT.Net.Ftp.FTPException, edtFTPnetPRO, Version=5.0.5.0, Culture=neutral, PublicKeyToken=0dce1ad63760d80b</ExceptionType><Message>File not found (code=550)</Message><StackTrace> at EnterpriseDT.Net.Ftp.FTPControlSocket.ValidateReply(FTPReply reply, String[] expectedReplyCodes)
at EnterpriseDT.Net.Ftp.FTPClient.a(String A_0)
at EnterpriseDT.Net.Ftp.FTPClient.a(String A_0, String A_1)
at EnterpriseDT.Net.Ftp.FTPClient.Get(String localPath, String remoteFile)
at EnterpriseDT.Net.Ftp.FTPConnection.DownloadFile(String localPath, String remoteFile)
at Virtual_FTP_Client.Form1.Download_Manager() in H:\Virtual FTP Client\Virtual FTP Client\Form1.cs:line 707
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()</StackTrace><ExceptionString>EnterpriseDT.Net.Ftp.FTPException: File not found (code=550)
at EnterpriseDT.Net.Ftp.FTPControlSocket.ValidateReply(FTPReply reply, String[] expectedReplyCodes)
at EnterpriseDT.Net.Ftp.FTPClient.a(String A_0)
at EnterpriseDT.Net.Ftp.FTPClient.a(String A_0, String A_1)
at EnterpriseDT.Net.Ftp.FTPClient.Get(String localPath, String remoteFile)
at EnterpriseDT.Net.Ftp.FTPConnection.DownloadFile(String localPath, String remoteFile)
at Virtual_FTP_Client.Form1.Download_Manager() in H:\Virtual FTP Client\Virtual FTP Client\Form1.cs:line 707
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()</ExceptionString></Exception></TraceRecord>
The program '[5404] Virtual FTP Client.vshost.exe: Managed' has exited with code 0 (0x0).
0 votes
by (162k points)
File not found (code=550).

The file you are asking for isn't on the server in the current directory.

Categories

...