Return-Path: Delivered-To: apmail-commons-issues-archive@minotaur.apache.org Received: (qmail 51820 invoked from network); 3 Mar 2010 10:06:58 -0000 Received: from unknown (HELO mail.apache.org) (140.211.11.3) by 140.211.11.9 with SMTP; 3 Mar 2010 10:06:58 -0000 Received: (qmail 17244 invoked by uid 500); 3 Mar 2010 10:06:51 -0000 Delivered-To: apmail-commons-issues-archive@commons.apache.org Received: (qmail 16998 invoked by uid 500); 3 Mar 2010 10:06:50 -0000 Mailing-List: contact issues-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: issues@commons.apache.org Delivered-To: mailing list issues@commons.apache.org Received: (qmail 16893 invoked by uid 99); 3 Mar 2010 10:06:50 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Mar 2010 10:06:50 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=10.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.140] (HELO brutus.apache.org) (140.211.11.140) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 03 Mar 2010 10:06:48 +0000 Received: from brutus.apache.org (localhost [127.0.0.1]) by brutus.apache.org (Postfix) with ESMTP id 68826234C4C5 for ; Wed, 3 Mar 2010 10:06:27 +0000 (UTC) Message-ID: <784063636.30911267610787427.JavaMail.jira@brutus.apache.org> Date: Wed, 3 Mar 2010 10:06:27 +0000 (UTC) From: "Philip Yao (JIRA)" To: issues@commons.apache.org Subject: [jira] Commented: (NET-61) [net] FTPClient.listFiles() hangs on Red Hat Linux MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 X-Virus-Checked: Checked by ClamAV on apache.org [ https://issues.apache.org/jira/browse/NET-61?page=3Dcom.atlassian.jir= a.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=3D12840558= #action_12840558 ]=20 Philip Yao commented on NET-61: ------------------------------- i have sloved. My code is not work like this: -------------------------------------------------------------- public boolean createDirectory(String pathName){=20 =09=09 boolean success =3D true; =09=09 try{ =09=09=09 if(!ftp.isConnected()) { =09=09=09=09 this.connectFtpServer(); =09=09=09 } =09=09=09 pathName =3D new String(pathName.getBytes("GBK"), "iso-8859-1");= =09=09=20 =09=09=09=20 =09=09=09 FTPFile[] ftpFileArr =3D ftp.listFiles(); =09=09=09 for(FTPFile f : ftpFileArr){ =09=09=09=09 if(pathName.equals(f.getName())){ =09=09=09=09=09 return true; =09=09=09=09 } =09=09=09 } =09=09=09=20 =09=09=09 ftp.makeDirectory(pathName); =20 =09=09 }catch (Exception ie){=20 =09=09=09 logger.error("=E5=88=9B=E5=BB=BA=E7=9B=AE=E5=BD=95=E5=87=BA=E9=94= =99=EF=BC=81", ie);=20 =09=09=09 success =3D false; =09=09 } =09=09 return success; =09 } ---------------------------------------------------- On the works fine (my notebook).I found the ftp log is : 220 Serv-U FTP Server v6.4 for WinSock ready... USER user 331 User name okay, need password. PASS user 230 User logged in, proceed. CWD ???????? 250 Directory changed to /???????? PASV 227 Entering Passive Mode (192,168,137,7,173,212) 227 SYST 215 UNIX Type: L8 PORT 192,168,137,7,4,152 200 PORT Command successful. LIST 150 Opening ASCII mode data connection for /bin/ls. 226 Transfer complete. ----------------------------------------------------- On the not work server(DELL 1950) .i found the log is no PASV. So I change the Code like this: public boolean createDirectory(String pathName){=20 =09=09 boolean success =3D true; =09=09 try{ =09=09=09 if(!ftp.isConnected()) { =09=09=09=09 this.connectFtpServer(); =09=09=09 } =09=09=09 pathName =3D new String(pathName.getBytes("GBK"), "iso-8859-1"); =09=09=09 ftp.enterLocalPassiveMode(); =09=09=09 FTPFile[] ftpFileArr =3D ftp.listFiles(); =09=09=09 for(FTPFile f : ftpFileArr){ =09=09=09=09 if(pathName.equals(f.getName())){ =09=09=09=09=09 return true; =09=09=09=09 } =09=09=09 } =09=09=09=20 =09=09=09 ftp.makeDirectory(pathName); =20 =09=09 }catch (Exception ie){=20 =09=09=09 logger.error("=E5=88=9B=E5=BB=BA=E7=9B=AE=E5=BD=95=E5=87=BA=E9=94= =99=EF=BC=81", ie);=20 =09=09=09 success =3D false; =09=09 } =09=09 return success; =09 } ------------------------------------------------------- Before call ftp.listFiles() , call ftp.enterLocalPassiveMode(); Frist; > [net] FTPClient.listFiles() hangs on Red Hat Linux > -------------------------------------------------- > > Key: NET-61 > URL: https://issues.apache.org/jira/browse/NET-61 > Project: Commons Net > Issue Type: Bug > Affects Versions: 1.4 > Environment: Operating System: Linux > Platform: PC > Reporter: George Van Treeck > Priority: Blocker > > A Java app that uses FTPClient to download a file from a website to Windo= ws XP=20 > works properly. But, when the same app runs on Linux to download the same= file=20 > from the same website, it hangs at listFiles(). > Using Java 1.5.0_03 on both the Windows XP and Linux. The version of Linu= x=20 > used is Fedor Red Hat Linux Core 3 with all the latest updates. The follo= wing=20 > segment of code from the program demonstrates the problem: > FTPClient ftp =3D new FTPClient(); > ftp.connect(host); > reply =3D ftp.getReplyCode(); > if (!FTPReply.isPositiveCompletion(reply)) { > final String ftpStatus =3D ftp.getReplyString(); > ftp.disconnect(); > throw new IOException( > "FTP server refused connection. Status: " + > ftpStatus); > } > ftp.login(user, password); > reply =3D ftp.getReplyCode(); > if (!FTPReply.isPositiveCompletion(reply)) { > final String ftpStatus =3D ftp.getReplyString(); > ftp.disconnect(); > throw new IOException( > "FTP server refused username/password. Status: " + > ftpStatus); > } > String[] list =3D ftp.listNames(); --=20 This message is automatically generated by JIRA. - You can reply to this email to add a comment to the issue online.