Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
4.6k views
in .NET FTP by (180 points)
Good afternoon,

We have an application that uses edtFTPnet to ftp files. The process was working perfectly for over a year with no failures. Recently, it has started failing but the failures are not guaranteed. When it fails, we usually see the following line in the log:

425 Try later, data connection in use.

Does anyone what could be causing this erratic behavior?

Thank you,

Michael

3 Answers

0 votes
by (162k points)
Perhaps this occurs when you have done quite a few transfers in quick succession? An FTP server would probably return this error when it has run out of sockets (from too many rapid transfers).
0 votes
by (180 points)
Thank you for the reply. Your answer matches our findings. We almost never get the error on the first files but usually in the middle or end. Once we get the error all subsequent attempts result in a failure - it seems after a little of time goes by. Our code FTPs one file at a time and we always instantiate a new FTPConnection object to do that (could that be the cause)? We also use a passive connection mode.

Is there a way to reduce the number of sockets in use? Don't they automatically get released? I've noticed that our socket is always using a different port which is probably why the server runs out the sockets.

We've enabled logging and set the level to ALL. Unfortunately, the logging doesn't show much when the transfer fails.
Here is an excerpt showing a succesful connection followed by 2 failures:

DEBUG [HostNameResolver] 2 Aug 2007 15:44:00.046 : ftp.cdm.com resolved to 63.118.227.180
DEBUG [FTPClient] 2 Aug 2007 15:44:00.046 : Connecting to 63.118.227.180:21
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.109 : 220 CDM FTP Server v1.0 Unathorized Access is Prohibited
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.109 : ---> USER ourusername
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.140 : 331 User name okay, need password.
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.140 : ---> PASS ********
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.171 : 230 User logged in, proceed.
DEBUG [FTPConnection] 2 Aug 2007 15:44:00.171 : Successfully logged in
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.171 : ---> TYPE I
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.203 : 200 Type set to I.
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.203 : ---> PWD
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.234 : 257 "/" is current directory.
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.234 : ---> CWD /
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.265 : 250 Directory changed to /
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.265 : ---> PWD
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.296 : 257 "/" is current directory.
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.296 : ---> MKD PWD Test/PWD Import Status
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.328 : 550 /PWD Test/PWD Import Status: Failed to create.
INFO [FTPControlSocket] 2 Aug 2007 15:44:00.328 : Expected reply codes = [200,250,257]
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.328 : ---> CWD PWD Test/PWD Import Status
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.359 : 250 Directory changed to /PWD Test/PWD Import Status
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.359 : ---> PWD
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.390 : 257 "/PWD Test/PWD Import Status" is current directory.
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.406 : ---> PASV
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.437 : 227 Entering Passive Mode (63,118,227,180,15,224)
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.437 : Server supplied address=63.118.227.180
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.437 : Server supplied port=4064
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.437 : Substituting server supplied IP (63.118.227.180) with remote host IP (63.118.227.180)
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.437 : NewPassiveDataSocket(63.118.227.180,4064)
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.468 : ---> STOR IMG_0702.JPG
DEBUG [FTPControlSocket] 2 Aug 2007 15:44:00.500 : 150 Opening BINARY mode data connection for IMG_0702.JPG.
DEBUG [FTPClient] 2 Aug 2007 15:45:27.671 : Transferred 3688923 bytes to remote host
DEBUG [FTPControlSocket] 2 Aug 2007 15:45:27.812 : 226-Maximum disk quota limited to 3072000 kBytes
DEBUG [FTPControlSocket] 2 Aug 2007 15:45:28.015 : Used disk quota 1907171 kBytes, available 1164828 kBytes
DEBUG [FTPControlSocket] 2 Aug 2007 15:45:28.015 : 226 Transfer complete.
DEBUG [FTPControlSocket] 2 Aug 2007 15:45:28.015 : ---> QUIT
DEBUG [FTPControlSocket] 2 Aug 2007 15:45:28.046 : 221 Goodbye!
DEBUG [HostNameResolver] 2 Aug 2007 15:45:28.046 : ftp.cdm.com resolved to 63.118.227.180
DEBUG [FTPClient] 2 Aug 2007 15:45:28.046 : Connecting to 63.118.227.180:21
DEBUG [HostNameResolver] 2 Aug 2007 15:45:28.625 : ftp.cdm.com resolved to 63.118.227.180
DEBUG [FTPClient] 2 Aug 2007 15:45:28.625 : Connecting to 63.118.227.180:21

Thank you,

Michael Tzoanos
0 votes
by (162k points)
You don't need a new FTPConnection object for each transfer - if you are using the same credentials and sending to the same server, just use the same FTPConnection.

Sockets do get automatically released, but the way TCP/IP works, there is a timeout period before they are available again to the operating system - normally 2 minutes or more. This is to prevent duplicate packets. So a lot of transfers in succession uses up a socket each time, and it takes a while for each to get released.

However using a new FTPConnection object for each transfer will use double the number of sockets - so it should make a considerable difference using one.

Categories

...