Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 317B7200C39 for ; Thu, 16 Mar 2017 14:05:47 +0100 (CET) Received: by cust-asf.ponee.io (Postfix) id 302FE160B7A; Thu, 16 Mar 2017 13:05:47 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 56AD0160B78 for ; Thu, 16 Mar 2017 14:05:46 +0100 (CET) Received: (qmail 46422 invoked by uid 500); 16 Mar 2017 13:05:45 -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 46411 invoked by uid 99); 16 Mar 2017 13:05:45 -0000 Received: from pnap-us-west-generic-nat.apache.org (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 16 Mar 2017 13:05:45 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id 0B735C32CF for ; Thu, 16 Mar 2017 13:05:45 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 0.652 X-Spam-Level: X-Spam-Status: No, score=0.652 tagged_above=-999 required=6.31 tests=[RP_MATCHES_RCVD=-0.001, SPF_NEUTRAL=0.652, WEIRD_PORT=0.001] autolearn=disabled Received: from mx1-lw-us.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 7bddrFGczZTw for ; Thu, 16 Mar 2017 13:05:43 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-lw-us.apache.org (ASF Mail Server at mx1-lw-us.apache.org) with ESMTP id 963215FD84 for ; Thu, 16 Mar 2017 13:05:42 +0000 (UTC) Received: from jira-lw-us.apache.org (unknown [207.244.88.139]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 01214E0538 for ; Thu, 16 Mar 2017 13:05:41 +0000 (UTC) Received: from jira-lw-us.apache.org (localhost [127.0.0.1]) by jira-lw-us.apache.org (ASF Mail Server at jira-lw-us.apache.org) with ESMTP id A6402254B7 for ; Thu, 16 Mar 2017 13:05:41 +0000 (UTC) Date: Thu, 16 Mar 2017 13:05:41 +0000 (UTC) From: "Sebb (JIRA)" To: issues@commons.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (NET-584) Error with org.apache.commons.net.ftp.FTPClient MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 archived-at: Thu, 16 Mar 2017 13:05:47 -0000 [ https://issues.apache.org/jira/browse/NET-584?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15927974#comment-15927974 ] Sebb commented on NET-584: -------------------------- Servers that don't send NOOP replies whilst a transfer is in progress seem to send the get/put completion response before the NOOP responses. That makes sense, since presumably the server does not even see the NOOP until the transfer completes. So long as no responses are lost, it does not matter which order they replies are processed by FTPClient, because it only looks for a successful code, not a particular success code. That is probably why it works for shorter files. > Error with org.apache.commons.net.ftp.FTPClient > ------------------------------------------------ > > Key: NET-584 > URL: https://issues.apache.org/jira/browse/NET-584 > Project: Commons Net > Issue Type: Bug > Components: FTP > Reporter: Kazantsev Andrey Sergeevich > > I have a question about using library commons-net-3.4.jar > Question is about org.apache.commons.net.ftp.FTPClient method setControlKeepAliveTimeout. > Read about using it on: > https://commons.apache.org/proper/commons-net/apidocs/org/apache/commons/net/ftp/FTPClient.html > When I use it in my code I get this error: > {code} > java.net.SocketTimeoutException: Read timed out > at java.net.SocketInputStream.socketRead0(Native Method) > at java.net.SocketInputStream.read(SocketInputStream.java:163) > at java.net.SocketInputStream.read(SocketInputStream.java:133) > at sun.nio.cs.StreamDecoder.readBytes(StreamDecoder.java:322) > at sun.nio.cs.StreamDecoder.implRead(StreamDecoder.java:364) > at sun.nio.cs.StreamDecoder.read(StreamDecoder.java:210) > at java.io.InputStreamReader.read(InputStreamReader.java:205) > at java.io.BufferedReader.fill(BufferedReader.java:165) > at java.io.BufferedReader.read(BufferedReader.java:186) > at org.apache.commons.net.io.CRLFLineReader.readLine(CRLFLineReader.java:58) > at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:313) > at org.apache.commons.net.ftp.FTP.__getReplyNoReport(FTP.java:303) > at org.apache.commons.net.ftp.FTPClient$CSL.cleanUp(FTPClient.java:3838) > at org.apache.commons.net.ftp.FTPClient._storeFile(FTPClient.java:695) > at org.apache.commons.net.ftp.FTPClient.__storeFile(FTPClient.java:643) > at org.apache.commons.net.ftp.FTPClient.storeFile(FTPClient.java:2033) > at ru.mdm.File.Transfer.FTP.PutRemoteFileBinary(FTP.java:192) > at ru.mdm.File.Transfer.TimeLimit.Thread.Protocol.PutRemoteFileBinaryThread.actionsToExecute(PutRemoteFileBinaryThread.java:23) > at ru.mdm.File.Transfer.TimeLimit.OperationThread.run(OperationThread.java:60) > {code} > Without enabling this option all works fine. > Here is the code: > {code} > package ru.mdm.File.Transfer; > import bin.ru.osa.common.utils.*; > import java.util.List; > import java.io.*; > import com.ibm.broker.javacompute.MbJavaComputeNode; > import com.ibm.broker.plugin.*; > import org.apache.commons.net.ftp.*; > import org.apache.commons.net.*; > import ru.mdm.File.Transfer.Options.OptionsXMLProcessor; > public class FTP implements Protocol > { > > FTPClient client = new FTPClient(); > > OptionsXMLProcessor optionsXMLProcessor; > > > boolean st; > String LastMessage = new String(); > > boolean ignoreErrors = false; > > > public FTP() > { > super(); > } > > protected void finalize() { disconnect(); } > > public void connect(String CntName, > String Host, > String Port, > String L, > String P) throws Exception > { > try > { > client.setControlKeepAliveTimeout(300); > client.connect(Host); > client.login(L, P); > CheckState(); > } > catch(Exception e) > { > LastMessage=client.getReplyString(); > if(LastMessage == null) LastMessage = e.getMessage(); > > e.printStackTrace(); > > throw e; > } > } > > public void disconnect() > { > try > { > if(client.isConnected()) > { > client.logout(); > client.disconnect(); > } > } > catch(Exception e) > { > e.printStackTrace(); > } > } > > public void chmod(String RemoteFile, String Rights) throws Exception > { > client.sendSiteCommand("chmod "+RemoteFile+" "+Rights); > CheckState(); > } > > > public void lsMB(MbElement InputDir,MbElement filelist) throws Exception, MbException > { > MbElement xfile; > > for (FTPFile file : client.listFiles((String)InputDir.evaluateXPath("string(SOURCE_PATH)"))) > { > if(!file.isFile()) continue; //-- No sub-dirs, No Symlinks ! > > xfile=filelist.createElementAsLastChild(MbElement.TYPE_NAME, "File", null); > xfile.createElementAsLastChild(MbElement.TYPE_NAME, "FileName", file.getName()); > xfile.createElementAsLastChild(MbElement.TYPE_NAME, "FileSize", file.getSize()); > xfile.createElementAsLastChild(MbElement.TYPE_NAME, "SourcePath", (String)InputDir.evaluateXPath("string(SOURCE_PATH)")); > xfile.createElementAsLastChild(MbElement.TYPE_NAME, "SourceGateway", (String)InputDir.evaluateXPath("string(GATEWAY_NAME)")); > } > } > > public void mkdir(String RemotePath) throws Exception > { > client.makeDirectory(RemotePath); > CheckState(); > } > > public void chdir(String RemotePath) throws Exception > { > client.changeWorkingDirectory(RemotePath); > CheckState(); > } > > public void delete(String RemotePath) throws Exception > { > client.deleteFile(RemotePath); > CheckState(); > } > > > > public void rename(String RemoteFileSrc, String RemoteFileDst) throws Exception > { > client.rename(RemoteFileSrc, RemoteFileDst); > CheckState(); > } > > > public void GetRemoteFileBinary(String RemoteFile, String LocalFile) throws Exception > { > client.enterLocalPassiveMode(); > client.setFileType(FTPClient.BINARY_FILE_TYPE); > client.retrieveFile(RemoteFile, > new FileOutputStream(LocalFile)); > > > CheckState(); > } > > public void PutRemoteFileBinary(String LocalFile, String RemoteFile) throws Exception > { > client.enterLocalPassiveMode(); > client.setFileType(FTPClient.BINARY_FILE_TYPE); > client.storeFile(RemoteFile, > new FileInputStream(LocalFile)); > CheckState(); > } > > > public void ignoreErrors(boolean x) { ignoreErrors=x; } > > > public boolean isOK() { return st; } > > public boolean isConnected() > { > boolean answer=false; > try { > answer = client.sendNoOp(); > } catch (IOException e) { > // TODO Auto-generated catch block > e.printStackTrace(); > } > st = answer; > return answer; > > } > > > public String LastMessage() { return LastMessage; }; > > > public void CheckState(boolean state) throws Exception > { > int reply = client.getReplyCode(); > if(FTPReply.isPositiveCompletion(reply)) st=true; > else st=false; > > LastMessage=client.getReplyString(); > > if(!st && !ignoreErrors) > throw new Exception(LastMessage); > } > > public void CheckState() throws Exception > { > int reply = client.getReplyCode(); > if(FTPReply.isPositiveCompletion(reply)) st=true; > else st=false; > > LastMessage=client.getReplyString(); > > if(!st && !ignoreErrors) > throw new Exception(LastMessage); > } > > public void attachOptions(OptionsXMLProcessor optionsXMLProcessor) throws Exception > { > this.optionsXMLProcessor = optionsXMLProcessor; > } > > public String getIP() { > > return ""; > } > > public boolean isIgnoreErrors() > { > return ignoreErrors; > } > } > {code} -- This message was sent by Atlassian JIRA (v6.3.15#6346)