[ https://issues.apache.org/jira/browse/NET-296?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Sebb reopened NET-296: ---------------------- I see. Sounds like a good plan. A local address such as in the reply: 227 Entering Passive Mode (192,168,201,220,195,108) may actually be valid if the original address was local. But can a local address ever be valid if the original address was not local? I suspect not. In which case, there is no need for the code to try connecting, it can just use the original address + reply port. (or if original was local, continue as usual). == I assume the server you are connecting to is not publicly accessible? Would you be able to help with testing any changes? > java.net.SocketException: Operation timed out error while entering Passive mode > ------------------------------------------------------------------------------- > > Key: NET-296 > URL: https://issues.apache.org/jira/browse/NET-296 > Project: Commons Net > Issue Type: Bug > Affects Versions: 2.0 > Environment: Windows XP, JDK 1.5.0_15, commons-net-2.0-jdk14.jar > Reporter: Hariprasad K S > Priority: Blocker > > Hi, > I am getting the following error while trying to connect to the FTP (Explicit). > java.net.SocketException: Operation timed out: connect:could be due to invalid address. > I am facing this error when i am running the code from the client machine which is in different domain...If i run the same code in the domain where ftp exists..it works fine without any issue...below is my code and the trace log....Pls help. > FTPSClient client = new FTPSClient("TLS",false); > client.addProtocolCommandListener(new PrintCommandListener(new PrintWriter(System.out))); > boolean _ftp_login = false; > > try { > String[] hname = ftpurl.split("//"); > client.setAuthValue("TLS"); > client.setRemoteVerificationEnabled(false); > client.connect("ftp.kotaklifeinsurance.com",22); > > int reply = client.getReplyCode(); > client.execPBSZ(0); > client.execPROT("P"); > > if (!FTPReply.isPositiveCompletion(reply)) { > client.disconnect(); > System.out.println("openFTPClient(): FTP server refused connection."); > throw new Exception("FTP server refused connection."); > } else { > try { > _ftp_login = client.login(userID, password); > } catch (Exception e) { > throw e; > } > if (_ftp_login) { > > client.enterLocalPassiveMode(); > > if (client.printWorkingDirectory() == null) > throw new Exception("Current working directory returned is null"); > client.changeWorkingDirectory("/XYZ/"); > fis = new FileInputStream(localfile); > ins = (InputStream)fis; > boolean flag = client.storeFile(filename,ins); > System.out.println("File saved to FTP : "+flag); > Error Trace : > 220 Unauthorized Access Prohibited. > AUTH TLS > 234 AUTH command ok. Expecting TLS Negotiation. > PBSZ 0 > 200 PBSZ command successful. > PROT P > 200 PROT command successful. > USER userid > 331 Password required for userid. > PASS password > 230 User logged in. > PWD > 257 "/" is current directory. > CWD /XYZ/ > 250 CWD command successful. > PWD > 257 "/XYZ" is current directory. > TYPE A > 200 Type set to A. > MODE I > 501 'MODE I': parameter not understood. > STRU F > 200 STRU F ok. > PASV > 227 Entering Passive Mode (192,168,201,220,195,108). > java.net.SocketException: Operation timed out: connect:could be due to invalid address > at java.net.PlainSocketImpl.socketConnect(Native Method) > at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:331) > at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:196) > at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:183) > at java.net.Socket.connect(Socket.java:478) > at java.net.Socket.connect(Socket.java:428) > at java.net.Socket.(Socket.java:335) > at java.net.Socket.(Socket.java:150) > at com.ibm.jsse.bs.(Unknown Source) > at com.ibm.jsse.JSSESocketFactory.createSocket(Unknown Source) > at org.apache.commons.net.ftp.FTPSSocketFactory.createSocket(FTPSSocketFactory.java:48) > at org.apache.commons.net.ftp.FTPClient._openDataConnection_(FTPClient.java:502) > at org.apache.commons.net.ftp.FTPSClient._openDataConnection_(FTPSClient.java:494) > at org.apache.commons.net.ftp.FTPClient.__storeFile(FTPClient.java:374) > at org.apache.commons.net.ftp.FTPClient.storeFile(FTPClient.java:1379) -- This message is automatically generated by JIRA. - For more information on JIRA, see: http://www.atlassian.com/software/jira