commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William Noto" <>
Subject [NET] FTP catching a SocketTimeoutException
Date Thu, 09 Jun 2005 18:33:34 GMT
Hi - 


I'm using the commons net package to do some FTP stuff from within my
application and despite the fact that my files seem to upload just fine, I
always catch a SocketTimeoutException.  I have a somewhat kludgy workaround
that lets me scrape along but I'm not happy with it because it's not working
as it should and these kinds of things are, well, just silly.


Infrastructure issues that may be relevant:  I am doing this over a VPN
connection (which makes debugging a little bit more complicated because I
cannot easily step through the code)  Everything works smoothly when I do my
FTP uploads manually using the ftp client from the bash prompt.


Any immediate thoughts on why it would hang until the timeout kicks in when
I run it from within java?  I'm using j2sdk1.4.2_05, connecting to an MVS
system over a VPN connection.  


My code:


try {


    if (isFilePresent(transmission.getOutputName())) {

          // ack file is already there... update status and move on...

          log.debug("file was already there. Updating records.");


    } else {

          log.debug("Attempting to send file: " + tranFilename);  

          int reply;

          InputStream in = new FileInputStream(f);

          // InputStream bin = new BufferedInputStream(in);

          boolean result = ftp.storeFile(f.getName(), in);

          reply = ftp.getReply();    




          if (FTPReply.isPositiveCompletion(reply)) {

            log.debug("positive reply on send.");


          } else {

            log.debug("no positive reply on send.");


              "Error sending file: " + tranFilename +  "\nReply =" + 



    } // file was not present; attempted send 

} catch (SocketTimeoutException e) {"Socket Timeout Exception caught while sending file."); 

} catch (IOException e) {

    log.error("sendNewFiles failed on sending: " + f.getName(), e);


    throw new InfrastructureException(e); } finally {




Thanks so much for any help -




William B. Noto    Open Finance    71 Gansevoort Street, Suite 2D, New York,
NY 10014
Tel  + 1 646 230 8666     Fax  + 1 646 230 8657 


  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message