Return-Path: Delivered-To: apmail-commons-user-archive@www.apache.org Received: (qmail 71296 invoked from network); 8 Mar 2009 08:24:24 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.2) by minotaur.apache.org with SMTP; 8 Mar 2009 08:24:24 -0000 Received: (qmail 11914 invoked by uid 500); 8 Mar 2009 08:24:20 -0000 Delivered-To: apmail-commons-user-archive@commons.apache.org Received: (qmail 11834 invoked by uid 500); 8 Mar 2009 08:24:19 -0000 Mailing-List: contact user-help@commons.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "Commons Users List" Delivered-To: mailing list user@commons.apache.org Received: (qmail 11823 invoked by uid 99); 8 Mar 2009 08:24:19 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 08 Mar 2009 00:24:19 -0800 X-ASF-Spam-Status: No, hits=2.2 required=10.0 tests=HTML_MESSAGE,SPF_PASS X-Spam-Check-By: apache.org Received-SPF: pass (athena.apache.org: domain of weixiang.ets@gmail.com designates 209.85.200.173 as permitted sender) Received: from [209.85.200.173] (HELO wf-out-1314.google.com) (209.85.200.173) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 08 Mar 2009 08:24:10 +0000 Received: by wf-out-1314.google.com with SMTP id 25so1261495wfa.27 for ; Sun, 08 Mar 2009 00:23:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:date:message-id:subject :from:to:content-type; bh=atLEYFF8n4CO6kwgL+mVVpnVD5tulODosD+J3RDN/90=; b=oH0SKD9BMWhv65s+DVu+2Rzdpx28LSpcV1pa+MZbqTm8tO2EirAa15Wdqal4CF4gZb nb77Mr7oTpT0B+y4be4QCxtlX+nKgs1uB1L34IgUgvjJe8NGUr9/LDISIMhnX+MNujdX sWT3YqwHPRNzGh73Ez47/qo+7AeqzgkgVbFqs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:date:message-id:subject:from:to:content-type; b=VP9yeTWEbsawowl5tObU1tRiLcjKswnHpEB6uB2b/xLTP/fbfeeSPCTMmAM9b5QOpE aH3R+9eVz2THPydP6W7wIVtw3/khfXGC7uBqQ7rLu2KXpy5M0SGGTeK0k3LUVjLLZ2DC Ci928op/RqwoiDRYZBgvYRUgyY0TUw0FZ8XJo= MIME-Version: 1.0 Received: by 10.142.171.3 with SMTP id t3mr1554890wfe.26.1236500630023; Sun, 08 Mar 2009 00:23:50 -0800 (PST) Date: Sun, 8 Mar 2009 16:23:50 +0800 Message-ID: Subject: [Net] From: weixiang tam To: user@commons.apache.org Content-Type: multipart/alternative; boundary=000e0cd18264d12dc20464973cc7 X-Virus-Checked: Checked by ClamAV on apache.org --000e0cd18264d12dc20464973cc7 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Hi All, Periodically, we are experiencing the FTP client thread is hang when we upload the file to the FTP server or when we initiate a connection to the FTP server. See the following thread dump from JBOSS server. It seem like after the common net FTPClient store the file, it will call the "FTP.__getReply()" to get the status code, and this should be the point that causing the thread hang. There is no Socket connection timeout error be thrown, and the thread just hang there forever. *"Uploading file to FTP"* *Thread: JMS SessionPool Worker-1* : priority:5, demon:true, threadId:355, threadState:RUNNABLE, threadLockName:null java.net.SocketInputStream.socketRead0(Native Method) java.net.SocketInputStream.read(Unknown Source) sun.nio.cs.StreamDecoder$CharsetSD.readBytes(Unknown Source) sun.nio.cs.StreamDecoder$CharsetSD.implRead(Unknown Source) sun.nio.cs.StreamDecoder.read(Unknown Source) java.io.InputStreamReader.read(Unknown Source) java.io.BufferedReader.fill(Unknown Source) java.io.BufferedReader.readLine(Unknown Source) java.io.BufferedReader.readLine(Unknown Source) *org.apache.commons.net.ftp.FTP.__getReply(FTP.java:294)* org.apache.commons.net.ftp.FTP.getReply(FTP.java:619) org.apache.commons.net.ftp.FTPClient.completePendingCommand(FTPClient.java:1244) org.apache.commons.net.ftp.FTPClient.__storeFile(FTPClient.java:401) org.apache.commons.net.ftp.FTPClient.storeFile(FTPClient.java:1379) ftp.adaptor.NetCommonsFTPClientManager.putAsciiFile(NetCommonsFTPClientManager.java:444) I am using the latest common-net release v2.0 and running in Solaris 10, JRE150_14, jboss AS 4.0.5. The following is the snapshot of the code that doing the initialization of FTP connection and the part that do the uploading of file to TP. As can be seen below, I have set the various set*timeOut method eg "setDefaultTimeOut", "setSoTimeout", "setDataTimeout" however, none of this will cause the time out in the connection. Could I know is the way I enable the timeout correctly set? //establish connectivity to FTP, set connection timeout to 60s public NetCommonsFTPClientManager(String host, int port) throws FTPException,FTPConnectionException { int reply = 0; try { _host = host; _port = port; _ftpClient = new org.apache.commons.net.ftp.FTPClient(); //test timeout _ftpClient.setDefaultTimeout(60 * 1000); System.out.println("NetCommon constructor setDefault connection timeout to 60s"); _ftpClient.connect(host,port); reply = _ftpClient.getReplyCode(); if(!org.apache.commons.net.ftp.FTPReply.isPositiveCompletion(reply)) { if(_ftpClient.isConnected()) _ftpClient.disconnect(); } else { reply = _ftpClient.getReplyCode(); } System.out.println("NetCommon constructor: connectionTimeout-->"+_ftpClient.getConnectTimeout()+" defaultTimeout-->"+_ftpClient.getDefaultTimeout()+ " soTimeout-->" +_ftpClient.getSoTimeout()); } catch(UnknownHostException ex) { System.out.println("Unknown host exception -->"); throw new FTPConnectionException(ex.getMessage()); } catch(IOException ex) { if(_ftpClient.isConnected()) { try{ _ftpClient.disconnect(); } catch(IOException iex){ } } throw new FTPConnectionException(ex.getMessage()); } } /** * Set the "SoTimeout" and "DataTimeout" to 60 s * Save the File to Server with the given InputStream. * @param localfile LocalFile as InputStream * @param remotefile File name to store on the server. * @throws FTPException - thrown upon FTP Error. */ public void putAsciiFile(InputStream localfile, String remotefile) throws FTPException { try { _ftpClient.setSoTimeout(60 * 1000); System.out.println("NetCommonsFTPClientManager.putAsciiFile setSoTimeout "); _ftpClient.setDataTimeout(60 * 1000); System.out.println("NetCommonsFTPClientManager.putAsciiFile setDataTimeout to 60s"); _ftpClient.storeFile(remotefile,localfile); } catch(FTPConnectionClosedException ex) { throw new FTPException(ex.getLocalizedMessage(), replyCodeToString(_ftpClient.getReplyCode())); } catch(IOException fex) { throw new FTPException(fex.getLocalizedMessage(), replyCodeToString(_ftpClient.getReplyCode())); } } After doing some search on the internet, I found someone has the similiar issue as I mentioned, like http://www.mail-archive.com/commons-user@jakarta.apache.org/msg11641.html https://issues.apache.org/jira/browse/NET-249 Could I know that is there any work around to resolve the Thread hang issue after execution of the FTP.__getReply? Or is the way I set the timeout wrong? Many thanks Wei Xiang --000e0cd18264d12dc20464973cc7--