Daniel, The server supports passive mode because I manually ftp and changed to passive mode without any problem. I put the setDataTimeout in MySocketFactory and still got timeout. I printed the host and port value and found they are correct. Here is MySocketFactory class, please let me know if it is correct. Thanks, Shawn public class MySocketFactory extends DefaultSocketFactory { private int connectTimeout = 0; private int dataTimeout = 0; /** * */ public MySocketFactory() { super(); } /* (non-Javadoc) * @see org.apache.commons.net.SocketFactory#createSocket(java.lang.String,int) */ public Socket createSocket(String host, int port) throws UnknownHostException, IOException { Socket s = new java.net.Socket(); System.out.println("host: "+host+" port: "+port); java.net.InetSocketAddress addr = new java.net.InetSocketAddress(host, port); s.connect(addr, connectTimeout); //s.connect(addr, 6000000); return s; } /** * @return */ public int getConnectTimeout() { return connectTimeout; } /** * @param i */ public void setConnectTimeout(int i) { connectTimeout = i; } public int getDataTimeout() { return dataTimeout; } public void setDataTimeout(int i){ dataTimeout = i; } } Code to call MySocketFactory, I notice the ftpClient.getPassiveHost() always returns as null. MySocketFactory MySocketFactory = new MySocketFactory(); MySocketFactory.setConnectTimeout(60000000); ftpClient.setSocketFactory(MySocketFactory); ftpClient.connect(aServer); ftpClient.login(aID,aPWD); ftpClient.enterLocalPassiveMode(); System.out.println("host1: "+ftpClient.getPassiveHost()); MySocketFactory.setDataTimeout(60000000);
"Daniel F. Savarese" <[EMAIL PROTECTED]> wrote: In message <[EMAIL PROTECTED]>, shaw shaw writes: > Thank you for your help. I tried to use setDataTimeout and still got time o >ut. I changed the timeout value for both FTPClient.setDataTimeout(timeout) an >d Sorry, it didn't completely register with me that this was a connection timeout. The right way to do set the connection timeout until Commons Net abandons older JVM compatibility is by creating a custom SocketFactory that uses a connection timeout when creating the socket. The data connection in Commons Net 1.4.x uses the socket factory to create the socket for the data connection. Is it possible that the remote server does not support passive mode? Without seeing the code to your socket factory, my guess is the problem is not with Commons Net. Your stack trace produces a ConnectException from Socket.connect from inside of your MySocketFactory.createSocket method. So that indicates that the connection attempt is being made and any failure is outside of the scope of FTPClient, which hands off the connection responsibility to MySocketFactory.createSocket from within FTPClient._openDataConnection_. Maybe print out the arguments that are passed to MySocketFactory.createSocket and make sure they are correct. Is it possible the wrong address is being given? daniel --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] --------------------------------- Looking for last minute shopping deals? Find them fast with Yahoo! Search.