I’m using Camel 2.15.2 with Apache Commons Net 3.3 on Java 8 deployed into a Tomcat container.
The issue is that consistently after processing just over 200 files (> 4000 files in the directory) the route stops, the FTP client disconnects and the following message is logged out:
[ogs.sharp-stream.com:21/root/] FtpConsumer WARN Error processing file RemoteFile[route/to/file] due to File operation failed: Connection closed without indication.. Code: 421. Caused by: [org.apache.camel.component.file.GenericFileOperationFailedException - File operation failed: Connection closed without indication.. Code: 421]
org.apache.camel.component.file.GenericFileOperationFailedException: File operation failed: Connection closed without indication.. Code: 421
at org.apache.camel.component.file.remote.FtpOperations.getCurrentDirectory(FtpOperations.java:713)
at org.apache.camel.component.file.remote.FtpOperations.retrieveFileToFileInLocalWorkDirectory(FtpOperations.java:440)
at org.apache.camel.component.file.remote.FtpOperations.retrieveFile(FtpOperations.java:310)
at org.apache.camel.component.file.GenericFileConsumer.processExchange(GenericFileConsumer.java:384)
at org.apache.camel.component.file.remote.RemoteFileConsumer.processExchange(RemoteFileConsumer.java:137)
at org.apache.camel.component.file.GenericFileConsumer.processBatch(GenericFileConsumer.java:211)
at org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:175)
at org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:187)
at org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:114)
at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)
at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: org.apache.commons.net.ftp.FTPConnectionClosedException: Connection closed without indication.
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:317)
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:294)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:483)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:608)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:582)
at org.apache.commons.net.ftp.FTP.pwd(FTP.java:1454)
at org.apache.commons.net.ftp.FTPClient.printWorkingDirectory(FTPClient.java:2658)
at org.apache.camel.component.file.remote.FtpOperations.getCurrentDirectory(FtpOperations.java:709)
... 15 more
This is the URI used at the begining of the related route.
As you can tell from the URI I’m also using a FileIdempotentRepository. It’s defined like this
<property name="fileStore" value="target/fileidempotent/.filestore1.dat" />
<property name="maxFileStoreSize" value="512000" />
<property name="cacheSize" value="250" />
</bean>
Any ideas why the connection might be closing before all files are processed?
org.apache.commons.net.ftp.FTPConnectionClosedException: Connection closed without indication.
Please follow the issue template and provide more details. issues like this do not provide any way of replicating the problem and spotting if it’s an Apache Commons FTP bug or an Android Upload Service bug. Thank you!
English is poor, please forgive me。
Using FTP to upload files to the window server was correct yesterday, but it went wrong today. The device system is android4.4.4
Sorry, but you have to follow what is in the issue template and provide necessary details, otherwise I couldn’t help you in any way
The same file, second pass will make mistakes ,and return «Error while uploading: xx to xx»
I don’t understand the code
try { String remoteFileName = getRemoteFileName(file); if (!ftpClient.storeFile(remoteFileName, localStream)) { throw new IOException("Error while uploading: " + file.getName(service) + " to: " + file.getProperty(PARAM_REMOTE_PATH)); } setPermission(remoteFileName, file.getProperty(PARAM_PERMISSIONS)); } finally { localStream.close(); }
The exception is thrown because the transfer of the file to your FTP directory is not possible. I don’t have the Apache Commons Net FTP docs at hand, but this may be due to permission policy for your FTP user or if the file already exists, in which case it doesn’t get overwritten.
Can you successfully upload the file for the first time? If I understand correctly, you get the exception only the second time you try to upload it.
Successfully upload the file for the first time.But,Some FTP servers can upload second times。
I’ll see if the FTP service is insufficient。
Example:
new FTPUploadRequest(mContext, _ip, _port)
.setUsernameAndPassword(_accout, _pwd)
.addFileToUpload(path, to)
.setNotificationConfig(config)
.setCreatedDirectoriesPermissions(new UnixPermissions(«777»))
.setSocketTimeout(301000)
.setConnectTimeout(301000)
Here it’s storeFile method JavaDoc. The method should overwrite the existing file the second time you try to make an upload.
The best way to check if the problem is in the library or in your FTP server config is to use one of the test FTP servers
You are right,this is FTP server Permission denied。
thanks
Below sample code is used with BPXBATCH to Connect to a MAINFRAME FTP Client.
When I run the below from Eclipse on my windows PC. its Successfull.
The issue comes when I try to execute the same with BPXBATCH on a Mainframe.
The code throws an FTPConnectionClosedException : Connection closed without indication
at client.connect(«XXX.XXX.XXX.XXX»);
FTPClient client = new FTPClient();
try {
client.connect("XXX.XXX.XXX.XXX");
client.login("user1", "pass123");
int reply ;
reply = client.getReplyCode();
System.out.println("Reply Code:"+reply);
if(client.isConnected())
client.logout();
else
System.out.println("Negative reply");
} catch(final Throwable t){
t.printStackTrace();
}
Эта ошибка возникает на файлы загрузки Linux, используя ftpclient
org.apache.commons.net.ftp.FTPConnectionClosedException: Connection closed without indication.
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:317)
at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:294)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:483)
at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:608)
at org.apache.commons.net.ftp.FTP.cwd(FTP.java:828)
at org.apache.commons.net.ftp.FTPClient.changeWorkingDirectory(FTPClient.java:1128)
at com.taotao.test.FTPTest.testFTP(FTPTest.java:22)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:325)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:78)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:57)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:89)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:41)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:541)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:763)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:463)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:209)
В конце концов, путем изменения разрешений файла на сервере его можно успешно выполнить, и этот метод использовался для сохранения файла для открытия разрешений этого пользователя для выполнения (X), я напрямую устанавливаю (rwx)
System Administrator
Jahia 8
Question
When trying to export profiles on my FTP I get the following error:
2021-07-15T13:53:24,280 | WARN | Camel (camel-1) thread #24 - timer://collectProfile | AggregateProcessor | 69 - org.apache.camel.camel-core - 2.20.2 | Error processing aggregated exchange. Exchange[ID-unomipp03-1626356169386-0-441]. Caused by: [org.apache.camel.component.file.GenericFileOperationFailedException - File operation failed: Connection closed without indication.. Code: 150]
org.apache.camel.component.file.GenericFileOperationFailedException: File operation failed: Connection closed without indication.. Code: 150
at org.apache.camel.component.file.remote.FtpOperations.doStoreFile(FtpOperations.java:615) ~[!/:2.20.2]
at org.apache.camel.component.file.remote.FtpOperations.storeFile(FtpOperations.java:526) ~[!/:2.20.2]
Answer
To fix this, you need to add disconnect=true
on your connection string, for instance
ftps://myFtpUser@my.host.com?password=thisIsAS3cret&binary=true&fileName=profiles-export-${date:now:yyyyMMddHHmm}.csv&fileExist=Append&disconnect=true&passiveMode=true