Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
7k views
in .NET FTP by (780 points)
My company has a series of VoIP devices that we setup via FTP. We get the files from the boxes, modify them, and send them back. The files are not very large in size (1-2 KB). I have a VB.NET application to do this. A simplified version of my GET function is as follows:

Public Function GetAllFilesFromBox(ByVal IPAddr as string) as boolean

        Dim i As Integer
        Dim FileName As String
        Dim ftp As FTPClient

        Try
            ftp = New FTPClient
            ftp.RemoteHost = IPAddr
            ftp.Timeout = FTPTimeout
            ftp.ConnectMode = FTPConnectMode.ACTIVE
            ftp.Connect()
            ftp.Login(UserName, Passwd)
            ftp.ChDir(BoxFileDir)

            For i = 0 to 20
                  FileName = FileLocation & FileNames(i)
                  ftp.Get(FileName, FileNames(i))
            Next
            
            Return True

       Catch
            ErrorLog.WriteException(ex)
            Return False
       Finally
            if (ftp.Connected) then
                 ftp.Quit
            end if
       End Try

End Function


I call this function asynchronouslly multiple times so that I can retreive files from more than one box at a time. I typically do 20 boxes at a time as my default. Note that each call to the function creates its own instance of the FTPClient. Once I reach my limit, I will start another box as one finishes. However, on Windows XP SP2, this often fails. I typically do not get all of the files from all of my boxes. Some finish completely, but on some I will get some of the files and then the function will fail with an exception "Unable to read data from the transport connection."

I have discovered the following. This only happens on XP SP2 with the firewall turned on. If I turn it off, I get all the files from all the boxes. If I switch to passive mode, it works fine, but other issues may prevent us from using passive mode. If I do each box one at a time, it works fine, but of course this takes forever. Even just 2 at a time will cause some failures. XP SP2 has a limit on the number of outbound connection attempts as detailed here:

http://www.speedguide.net/read_articles.php?id=1497

I tried the fix, but it didn't help. Any ideas as to what is going on? I just downloaded the new 1.2.3 version of edtFTPnet yesterday and nothing in there seemed to fix the problem, but this is the version that I am currently using.

11 Answers

0 votes
by (780 points)
Thanks. I'll keep that in mind about the SFTP, although I doubt our devices support it.

I have discovered a few more things in testing. I tried making sure that the FTPClient for each device had non-overlapping ranges for the ActivePortRange. I gave each a range of 50 ports, but I only get a max of 21 files from each device. I didn't add the ports to the firewall because I couldn't exactly add 1000 individual ports 1 at a time, but at least they no longer overalapped. In my logs afterward, I confirmed that no port was ever used more than once for a single download. Still though I was able to get all the files from some devices, but not from others, even without any ports added to the firewall. And it's totally random. Sometimes a device works and sometimes it doesn't.

I also found that if I simply go into the Windows services and restart the Application Layer Gateway Service everything works perfectly.

I'm not sure what either of these bits of information means.

Categories

...