Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.9k views
in Java FTP by (120 points)
Hi,

I have a java service in a EAI tool which uses EDTFTPj 1.5.2 for file transfers.

The files are sent to different servers .. (more than 50 different servers and increasing .. ) based on user requests. The java service is activated on receiving a trigger message in the queue with information of the remote server and all the details required to transfer the file (username, password, directory, filename ..etc.).

There are times when the java service hangs and blocks all the other messages in the queue. I am using FTPClient.setTimeout() .. and was able to solve the problem of ConnectionTimedOut exceptions which I used to get earlier.

My analysis is that when FTPClient.connect() command is run . the server doesn't reply and hence the programs goes into a hung state. How do I rectify this.

the code I am using is like given below..

ftpClient.setRemoteHost( strHostname );
ftpClient.setRemotePort( Integer.parseInt( strFTPPort ) );
ftpClient.connect();
ftpClient.setTimeout( 1500000 );
logger.info( "Before Login to Host " + strHostname + " as " + strUserName);
ftpClient.login( strUserName, strPassword );
logger.info( " CONNECTED TO HOST " + strHostname + " as " + strUserName );
ftpClient.setConnectMode( FTPConnectMode.PASV );
ftpClient.setType( FTPTransferType.BINARY );

how do I overcome this problem, The code is in production for more than 5 months and I am having these problems twice or thrice on a weekly basis these days. I have not enabled the EDTFTPj logging because I am using the EAI tool logging .. I don't get any exceptions or errors when the FTPClient.connect() hangs.

I have searched in the forum and didn't get a solution. Kindly help.

thanks and regards,
Umesh

1 Answer

0 votes
by (162k points)
Earlier versions of Java don't support a timeout in the Socket constructor. It just connects and hangs.

In FTPControlSocket, you could modify the code to do

Socket s = new Socket();
s.setSoTimeout(timeout);
s.connect()

or something like that. We'll change to this eventually, but 1.2 & 1.3 users still use the library.

Categories

...