commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Gregor Schmidt" <gregor.schm...@utanet.at>
Subject Re: [net] FTP client fails if a modem connection is used
Date Wed, 01 Aug 2012 08:54:44 GMT
Hello,

I downloaded the FTPClient class (3.0.1) from Commons Net and analysed the 
code, snippets see below. I found that a user set value for 
controlKeepAliveReplyTimeout is internally used as a SocketTimeout (561, 
562, 3292). Due to the raised exception at the end of the file upload, the 
function cleanUp() is no longer called (3312) and the restore of the 
original SocketTimeout isn't done any more. I verified that with my settings 
controlKeepAliveReplyTimeout=1000 and SocketTimeout=10000. I always got 
SocketTimeout=1000 after the exception at the end of the file upload.

I was astonished seeing that. I'd have expected a different usage of the 
timeouts according to their naming and the API documentation. As a 
consequence I removed these code lines from my implementation

keepAliveTimeout = 300;
keepAliveReplyTimeout = 1000;
ftpC.setControlKeepAliveTimeout(keepAliveTimeout);
ftpC.setControlKeepAliveReplyTimeout(keepAliveReplyTimeout);

... and the FTP client worked with modem and bad mobil connections!!!!

As far as I can see the FTPClient class don't implement the functions 
documented for "Control channel keep-alive" with routers. If that were the 
case, it should be brought to the attention of the developers. Please 
comment on my post.

Best regards,
Gregor



545     private boolean __storeFile() {
            ....
560         CSL csl = null;
561         if (__controlKeepAliveTimeout > 0) {
562             csl = new CSL(this, __controlKeepAliveTimeout, 
__controlKeepAliveReplyTimeout);
563         }
            ....
566         try
567         {
568             Util.copyStream(local, output, getBufferSize(),
569                     CopyStreamEvent.UNKNOWN_STREAM_SIZE, 
__mergeListeners(csl),
570                     false);
571         }
            ....
586     }



3279    private static class CSL implements CopyStreamListener {
        ....
3288        CSL(FTPClient parent, long idleTime, int maxWait) throws 
SocketException {
3289            this.idle = idleTime;
3290            this.parent = parent;
3291            this.currentSoTimeout = parent.getSoTimeout();
3292            parent.setSoTimeout(maxWait);
3293        }
        ....
3312        void cleanUp() throws IOException {
3313            while(notAcked-- > 0) {
3314                parent.__getReplyNoReport();
3315            }
3316            parent.setSoTimeout(currentSoTimeout);
3317        }

        ....
3319    }


---------------------------------------------------------------------
To unsubscribe, e-mail: user-unsubscribe@commons.apache.org
For additional commands, e-mail: user-help@commons.apache.org


Mime
View raw message