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

Sebb commented on NET-258:
--------------------------

Thanks for the patch. 

However, as it stands, it's not guaranteed to always work. The boolean 
stopKeepAlive is set by one thread and read by another, and therefore needs to 
be volatile (or read in a sync. block). The code assumes that NET FTP is 
thread-safe - I'm not sure that is the case.

Also, what happens if the thread sends a NOOP whilst the main code is busy 
doing a transfer? Or vice versa? I suspect that would cause errors.

==

I'm not sure a separate keep-alive thread is the way to go here - too tricky to 
co-ordinate.

Maybe it would be possible to use some kind of worker queue to ensure requests 
are single-threaded.
Keep-alive could be supported by having the worker use wait with timeout and 
send a NOOP if there was nothing else to do.

> Implement A Keepalive Mechanism
> -------------------------------
>
>                 Key: NET-258
>                 URL: https://issues.apache.org/jira/browse/NET-258
>             Project: Commons Net
>          Issue Type: Improvement
>    Affects Versions: 2.0
>            Reporter: Rory Winston
>            Assignee: Rory Winston
>         Attachments: ftp-keepalive.diff
>
>
> For routers/firewalls that terminate idle connections, a separate heartbeat 
> mechanism may need to be implemented to keep the control connection active.
> Some potential issues:
> * Synchronization between a heartbeat write and a __getReply() on an active 
> control connection command;
> * Should use the NOOP command as a heartbeat signal;
> * Make the timeout configurable;
> * Default SocketImpl::setKeepAlive() wont do here.

-- 
This message is automatically generated by JIRA.
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        

Reply via email to