Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
3.5k views
in Java FTP by (300 points)
So my company has been suffering from intermittent internet connections, minor brown-outs and packet losses. If this happens while the edtFTPj/PRO package is working, the following can sometimes occur (listed below). These two lines infinitely loop, the thread never failing and never exiting.

Obviously there is a bug here where keepAlive() is trying to work at the same time as cancelTransfer(), but does anyone have any short term options that might solve the problem? Unfortunately this isn't reproduceable by us (meaning, we do everything we can to make our internet connection stable and obviously can't mess with it just to test this).

Any suggestions?


2012-06-27 23:59:10,965 INFO  [STDOUT][FTPKeepAlive] WARN [FTPConnection] 27 Jun 2012 23:59:10.965 : keepAlive() failed - trashing connection: The FTP client has not yet connected to the server.  The requested action cannot be performed until after a connection has been established.
2012-06-27 23:59:10,965 INFO  [STDOUT][FTPKeepAlive] WARN [FTPClient] 27 Jun 2012 23:59:10.965 : cancelTransfer() called
2012-06-27 23:59:40,971 INFO  [STDOUT][FTPKeepAlive] WARN [FTPConnection] 27 Jun 2012 23:59:40.971 : keepAlive() failed - trashing connection: The FTP client has not yet connected to the server.  The requested action cannot be performed until after a connection has been established.
2012-06-27 23:59:40,972 INFO  [STDOUT][FTPKeepAlive] WARN [FTPClient] 27 Jun 2012 23:59:40.971 : cancelTransfer() called

4 Answers

0 votes
by (162k points)
Hi, I've been taking a look at this and am wondering what version of edtFTPj/PRO you are using. Can you let us know?
0 votes
by (300 points)
Sorry, Monday was a holiday here.

We are using 4.0.0 of edtFTPj/PRO (from the manifest file).

Also requested was some snippets of how we are using the code. Very simply is the answer, details below. Note these lines are pulled from various classes, so it's basically pseudo-code at this point. Upload is almost identical. The hang has happened in both directions.

   ftp = new SecureFileTransferClient();

   ftp.addErrorListener(new FTPErrorListener());
   ftp.setTimeout(60000);
   // set remote host
   ftp.setRemoteHost(getHost());
   ftp.setRemotePort(getPort());
   ftp.setUserName(getUser());
   ftp.setPassword(getPassword());
        ftp.setMaxTransferRate(256);

        InputStream ftpIn = ftp.downloadStream(remoteFileName);
   OutputStream foutLocal = new FileOutputStream(sLocalTmpFile);
   try {
      byte[] buffer = new byte[2048]; 
      int len;
      while ((len = ftpIn.read(buffer)) != -1) {
          foutLocal.write(buffer, 0, len);
      }
        } catch (Exception e){
       ftpIn.close();
       throw e;
   } 
   finally {
       foutLocal.flush();
       foutLocal.close(); 
   }
   ftpIn.close();

0 votes
by (162k points)
It's not obvious how this is happening. Is it possible to give us a more complete log file that shows us what is happening prior to the loop starting?
0 votes
by (300 points)
Again, my apologies for the delay.

I will endeavour to get more complete logging, we'll have to go to tape backups to get it. I will try next week.

Interestingly, we did recently upgrade our shabby internet connection to dedicated Fiber, and we haven't suffered the problem since.

Categories

...