You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by bu...@apache.org on 2005/07/18 13:56:06 UTC

DO NOT REPLY [Bug 35777] New: - FTPClient.connect() does not timeout

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=35777>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=35777

           Summary: FTPClient.connect() does not timeout
           Product: Commons
           Version: 1.3 Final
          Platform: Sun
        OS/Version: Solaris
            Status: NEW
          Severity: normal
          Priority: P2
         Component: Net
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: sms@pccl.demon.co.uk


I have a Java application which transmits files using FTPClient. The system is 
running live and usually has no problems. Sometimes, we cannot connect to the 
FTP server, the connect() call timesout after 3mins 45 secs and we try later - 
usually successfully.

Over the weekend we had a situation where the application hung. The logs showed 
that FTPClient.connect() had been called but had not returned. Neither had it 
thrown an exception.

I have managed to reproduce this condition by writing a SimpleServer class 
(code attached). The SimpleServer accepts a TCP connection on port 6001 but 
does not enter the FTP dialogue. I called the SimpleServer using client.connect
("localhost", 6001). The connection was accepted by the SimpleServer, the call 
to connect() did not return or throw an exception.

Although I had to reproduce this problem by creating an artificial situation, 
the problem does occur on real, live systems. So, a fix would really benefit 
the user community.

Kind Regards


SimpleServer.java:
==================

import java.io.*;
import java.net.*;
import java.util.*;

public class SimpleServer {

	SimpleServer(int port){
		ServerSocket		socket;
		Socket				connection;
		BufferedInputStream	is;
		boolean				connected	= false;

		try{
			System.out.println("Listen");
			socket		= new ServerSocket(port);

			System.out.println("Accept");
			connection	= socket.accept();
			connected	= true;

			System.out.println("Setup streams\n");
			is	= new BufferedInputStream 
(connection.getInputStream());

			while(connected){
				int 	size;
				byte[]	buff	= new byte[1024];

				System.out.println("Reading");
				size	= is.read(buff, 0, buff.length);

				if (size >= 0){
					System.out.println("Read [" + size 
+ "]: " + new String(buff, 0, size));
				}
				else{
					System.out.println("no more data");
					connected	= false;
				}
			}
		}
		catch (Exception e){
			System.err.println("Exception: " + e);
			System.exit(1);
		}
	}

	public static void main (String args[]){
		SimpleServer ss	= new SimpleServer(6001);
	}

}

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org