[ 
https://issues.apache.org/jira/browse/CAMEL-8860?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14605492#comment-14605492
 ] 

Grzegorz Grzybek commented on CAMEL-8860:
-----------------------------------------

[~himanshu], could you provide more details? Could you enable DEBUG logging for 
{{org.apache.camel.component.file.remote}} logger and attach the logs?
I tried with special socket factory to see when sockets are created and 
connected and I had single connection reused for all writes:
{noformat}
2015-06-29 13:36:43,103 [main           ] INFO  NameProducerConnectionLeakTest 
- Creating socket 1642030774
2015-06-29 13:36:43,103 [main           ] INFO  NameProducerConnectionLeakTest 
- connecting socket 1642030774 to localhost/127.0.0.1:21000
2015-06-29 13:36:43,194 [main           ] DEBUG RemoteFileProducer             
- Connected and logged in to: 
Endpoint[ftp://admin:xxxxxx@localhost:21000/out/?delete=true&disconnect=false&fileName=%24%7Bfile%3Aname%7D&ftpClient.socketFactory=%23sf&passiveMode=false&tempFileName=%24%7Bfile%3Aonlyname%7D.part]
2015-06-29 13:36:43,292 [main           ] DEBUG FtpOperations                  
- About to store file: file1.txt.part using stream: 
java.io.ByteArrayInputStream@2f7298b
2015-06-29 13:36:43,336 [main           ] DEBUG FtpOperations                  
- Took 0.044 seconds (44 millis) to store file: file1.txt.part and FTP client 
returned: true
2015-06-29 13:36:43,337 [main           ] DEBUG RemoteFileProducer             
- Wrote [out/file1.txt.part] to 
[Endpoint[ftp://admin:xxxxxx@localhost:21000/out/?delete=true&disconnect=false&fileName=%24%7Bfile%3Aname%7D&ftpClient.socketFactory=%23sf&passiveMode=false&tempFileName=%24%7Bfile%3Aonlyname%7D.part]]
2015-06-29 13:36:43,337 [main           ] DEBUG FtpOperations                  
- Renaming file: out/file1.txt.part to: out/file1.txt
2015-06-29 13:36:43,343 [main           ] DEBUG ProducerCache                  
- >>>> 
Endpoint[ftp://admin:xxxxxx@localhost:21000/out/?delete=true&disconnect=false&fileName=%24%7Bfile%3Aname%7D&ftpClient.socketFactory=%23sf&passiveMode=false&tempFileName=%24%7Bfile%3Aonlyname%7D.part]
 Exchange[Message: Hello World]
2015-06-29 13:36:43,437 [main           ] DEBUG FtpOperations                  
- About to store file: file2.txt.part using stream: 
java.io.ByteArrayInputStream@6eda5c9
2015-06-29 13:36:43,479 [main           ] DEBUG FtpOperations                  
- Took 0.042 seconds (42 millis) to store file: file2.txt.part and FTP client 
returned: true
2015-06-29 13:36:43,481 [main           ] DEBUG RemoteFileProducer             
- Wrote [out/file2.txt.part] to 
[Endpoint[ftp://admin:xxxxxx@localhost:21000/out/?delete=true&disconnect=false&fileName=%24%7Bfile%3Aname%7D&ftpClient.socketFactory=%23sf&passiveMode=false&tempFileName=%24%7Bfile%3Aonlyname%7D.part]]
2015-06-29 13:36:43,481 [main           ] DEBUG FtpOperations                  
- Renaming file: out/file2.txt.part to: out/file2.txt
2015-06-29 13:36:43,487 [main           ] DEBUG ProducerCache                  
- >>>> 
Endpoint[ftp://admin:xxxxxx@localhost:21000/out/?delete=true&disconnect=false&fileName=%24%7Bfile%3Aname%7D&ftpClient.socketFactory=%23sf&passiveMode=false&tempFileName=%24%7Bfile%3Aonlyname%7D.part]
 Exchange[Message: Hello World]
2015-06-29 13:36:43,580 [main           ] DEBUG FtpOperations                  
- About to store file: file3.txt.part using stream: 
java.io.ByteArrayInputStream@55b7a4e0
2015-06-29 13:36:43,623 [main           ] DEBUG FtpOperations                  
- Took 0.043 seconds (43 millis) to store file: file3.txt.part and FTP client 
returned: true
2015-06-29 13:36:43,625 [main           ] DEBUG RemoteFileProducer             
- Wrote [out/file3.txt.part] to 
[Endpoint[ftp://admin:xxxxxx@localhost:21000/out/?delete=true&disconnect=false&fileName=%24%7Bfile%3Aname%7D&ftpClient.socketFactory=%23sf&passiveMode=false&tempFileName=%24%7Bfile%3Aonlyname%7D.part]]
2015-06-29 13:36:43,625 [main           ] DEBUG FtpOperations                  
- Renaming file: out/file3.txt.part to: out/file3.txt
2015-06-29 13:36:43,629 [main           ] INFO  NameProducerConnectionLeakTest 
- 
********************************************************************************
2015-06-29 13:36:43,629 [main           ] INFO  NameProducerConnectionLeakTest 
- Testing done: 
testConnectionLeak(org.apache.camel.component.file.remote.FileToFtpTempFileNameProducerConnectionLeakTest)
2015-06-29 13:36:43,629 [main           ] INFO  NameProducerConnectionLeakTest 
- Took: 0.606 seconds (606 millis)
2015-06-29 13:36:43,629 [main           ] INFO  NameProducerConnectionLeakTest 
- 
********************************************************************************
2015-06-29 13:36:43,629 [main           ] DEBUG CamelTestSupport               
- tearDown test
2015-06-29 13:36:43,630 [main           ] DEBUG SharedProducerServicePool      
- Stopping service pool: 
org.apache.camel.impl.SharedProducerServicePool@166fa74d
2015-06-29 13:36:43,631 [main           ] DEBUG RemoteFileProducer             
- Disconnecting from: 
Endpoint[ftp://admin:xxxxxx@localhost:21000/out/?delete=true&disconnect=false&fileName=%24%7Bfile%3Aname%7D&ftpClient.socketFactory=%23sf&passiveMode=false&tempFileName=%24%7Bfile%3Aonlyname%7D.part]
2015-06-29 13:36:43,632 [main           ] INFO  NameProducerConnectionLeakTest 
- closing socket 1642030774
{noformat}


> Too many connection in TIME_WAIT when tempfilename is set in the FTP producer 
> URI.
> ----------------------------------------------------------------------------------
>
>                 Key: CAMEL-8860
>                 URL: https://issues.apache.org/jira/browse/CAMEL-8860
>             Project: Camel
>          Issue Type: Bug
>          Components: camel-ftp
>    Affects Versions: 2.14.0
>            Reporter: Himanshu Mittal
>            Assignee: Grzegorz Grzybek
>
> So many connections remain in TIME_WAIT state while configuring a FTP 
> producer route with tempfilename property in FTP producer. 
> Files are writen using producer template.
> Producertemplate.sendBodyAndHeader(producerURI, Exchange.FILE_NAME, fileName) 
> to write file to destination. 
> Producer URI : 
> {{ftp://<USER@MACHINE_ADDRESS>//?password=RAW(PASSWORD)&binary=true&passiveMode=false&delete=true&pollStrategy=#ConsumerPollStrategy&disconnect=false&tempFileName=/temp/hello.tmp&initialDelay=10&throwExceptionOnConnectFailed=true&reconnectDelay=10&maximumReconnectAttempts=0&maxMessagesPerPoll=100&readLock=changed&readLockCheckInterval=500&readLockMinLength=1&sendEmptyMessageWhenIdle=true}}
> fileName: {{file.tmp}}
> We are writing ~ 2000 files . First files are written to temp directory then 
> moved to destination. Connections opened for tempfiles are not re used to 
> write temporary files and we run out of connection after writing 1000 files. 
> Route resumes once connections are released. 
> Is there a way we can  reuse connection to write temporary files also.
> Once tempfilename is removed from the configuration then single connection is 
> used for ftp transfer.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to