You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by hardikdesai81 <ha...@gmail.com> on 2013/07/29 17:40:34 UTC

Camel Spring DSL - FTP consumerTemplate.receive gives FTP time out

Hi folks, 

I am using Camel with Spring DSL. I have implemented the FTP producer
correctly and I am able to generated a JSON object at runtime and send it to
an FTP Endpoint. However, when trying to consume that same JSON using
Consumer Template, I am facing an FTP connection timeout problem when I
leave my server running for some time. Please see details below.

Following is my Spring context XML: 
        <camel:camelContext id="camelContext">
                <camel:template id="camelTemplate" />
                <camel:consumerTemplate id="consumerTemplate" />
                <camel:endpoint id="myFTPEndpoint" 
                       
uri="${ftp.protocol}://${ftp.userName}@${ftp.host}${ftp.remoteDirectory}?password=${ftp.password}&amp;passiveMode=${ftp.passiveMode}&amp;download=${ftp.download}&amp;localWorkDirectory=${ftp.localWorkDirectory}"
/>
        </camel:camelContext>

Following is my Consumer code: 
@Service 
public class FtpReceiverServiceImpl implements FtpReceiverService { 

        private final ConsumerTemplate consumerTemplate; 
        private final Endpoint ftpEndpoint; 
        
        @Autowired 
        FtpReceiverServiceImpl(ConsumerTemplate consumerTemplate, Endpoint
ftpEndpoint) { 
                this.consumerTemplate = consumerTemplate; 
                this.ftpEndpoint = ftpEndpoint; 
        } 

        @Override 
        public List<String> receiveFiles() throws InterruptedException { 
                List<String> files = new ArrayList<String>(); 
                Exchange ex = consumerTemplate.receive(ftpEndpoint, 5000); 
                while(ex!=null) { 
                        files.add((String)
ex.getIn().getHeader("CamelFileName")); 
                        ex = consumerTemplate.receive(ftpEndpoint, 5000); 
                } 
                return files; 
        } 
} 

When I leave the server running for few minutes, and then try
consumerTemplate.receive(ftpEndpoint, 5000), I get the following time out
exception.

WARN :
org.apache.camel.component.file.remote.RemoteFilePollingConsumerPollStrategy
- Trying to recover by disconnecting from remote server forcing a re-connect
at next poll: ftp://anonymous@XX.XX.XX.XX:21
WARN : org.apache.camel.component.file.remote.FtpConsumer - Error occurred
while disconnecting from ftp://anonymous@XX.XX.XX.XX:21 due: File operation
failed: 421 Terminating connection.
 FTP response 421 received.  Server closed connection.. Code: 421. This
exception will be ignored.
WARN : org.apache.camel.component.file.remote.FtpConsumer - Consumer
FtpConsumer[ftp://anonymous@XX.XX.XX.XX/Test/Test1?download=true&localWorkDirectory=D%3A%2Fmetamodel&passiveMode=false&password=******]
failed polling endpoint:
Endpoint[ftp://anonymous@XX.XX.XX.XX/Test/Test1?download=true&localWorkDirectory=D%3A%2Fmetamodel&passiveMode=false&password=******].
Will try again at next poll. Caused by:
[org.apache.camel.component.file.GenericFileOperationFailedException - File
operation failed: 421 Timeout (120 seconds): closing control connection.
 FTP response 421 received.  Server closed connection.. Code: 421]
org.apache.camel.component.file.GenericFileOperationFailedException: File
operation failed: 421 Timeout (120 seconds): closing control connection.
 FTP response 421 received.  Server closed connection.. Code: 421
	at
org.apache.camel.component.file.remote.FtpOperations.getCurrentDirectory(FtpOperations.java:700)
	at
org.apache.camel.component.file.remote.FtpConsumer.pollDirectory(FtpConsumer.java:45)
	at
org.apache.camel.component.file.GenericFileConsumer.poll(GenericFileConsumer.java:115)
	at
org.apache.camel.impl.ScheduledPollConsumer.doRun(ScheduledPollConsumer.java:142)
	at
org.apache.camel.impl.ScheduledPollConsumer.run(ScheduledPollConsumer.java:92)
	at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:441)
	at
java.util.concurrent.FutureTask$Sync.innerRunAndReset(FutureTask.java:317)
	at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:150)
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$101(ScheduledThreadPoolExecutor.java:98)
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.runPeriodic(ScheduledThreadPoolExecutor.java:180)
	at
java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:204)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.runTask(ThreadPoolExecutor.java:886)
	at
java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:908)
	at java.lang.Thread.run(Thread.java:662)
Caused by: org.apache.commons.net.ftp.FTPConnectionClosedException: FTP
response 421 received.  Server closed connection.
	at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:363)
	at org.apache.commons.net.ftp.FTP.__getReply(FTP.java:290)
	at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:479)
	at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:552)
	at org.apache.commons.net.ftp.FTP.sendCommand(FTP.java:601)
	at org.apache.commons.net.ftp.FTP.pwd(FTP.java:1399)
	at
org.apache.commons.net.ftp.FTPClient.printWorkingDirectory(FTPClient.java:2469)
	at
org.apache.camel.component.file.remote.FtpOperations.getCurrentDirectory(FtpOperations.java:696)
	... 13 more

Am I missing a configuration parameter in my FTP URI Endpoint that I have
defined in the Spring context XML above?




--
View this message in context: http://camel.465427.n5.nabble.com/Camel-Spring-DSL-FTP-consumerTemplate-receive-gives-FTP-time-out-tp5736441.html
Sent from the Camel - Users mailing list archive at Nabble.com.