https://issues.apache.org/bugzilla/show_bug.cgi?id=45817


Anuja <[EMAIL PROTECTED]> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEEDINFO                    |ASSIGNED




--- Comment #2 from Anuja <[EMAIL PROTECTED]>  2008-09-18 22:13:33 PST ---
import org.apache.commons.net.ftp.FTPClient;
import org.apache.commons.net.ftp.FTPReply;


I am using the above mentined Apache classes to connect to FTP
A thread is continuously polling(15 min) FTP for a particular file and
dwonloading if this is available in FTP

This thread was working fine until a Socket exception came. May be due to slow
network. In the next iteetarion of the thread it came uptil 
ftpClient.connect(url);
after that no response from FTP.

public boolean connect(String url, String user, String password) throws
FtpException{
        if(log.isDebugEnabled()){
                 log.debug("Inside Connect function>> ");
                 log.debug("url>> "+url);
                 log.debug("user>> "+user);
                 log.debug("password>> "+password);
            }

        boolean success = false;
        try{
            if(url == null || url.trim().length() == 0){
                throw new FtpException(FtpException.FTP_CONNECTION_FAILED, "ftp
url not provided");
            }
            if(log.isDebugEnabled()){
                log.debug("Just before Connect function>> ");
            }
            ftpClient.setDefaultTimeout(2000);
            //ftpClient.setDataTimeout(1);
            //ftpClient.setSoTimeout(20000);
            ftpClient.connect(url);

            if(log.isDebugEnabled()){
                log.debug("Just before Connect function>> ");
            }
            success = ftpClient.login(user, password);
            if(success){
                if(log.isDebugEnabled()){
                    log.debug("Login to ftp successfull. url: " + 
                        url + ", user : " + user + ", password : " + password);
                }
            }else{
                throw new FtpException(FtpException.FTP_CONNECTION_FAILED,
"Could not login to ftp. url: " + 
                        url + ", user : " + user + ", password : " + password);
            }
        }catch(FtpException fe){
            ExploitLogger.error(MessageCodes.CD_4007,
MessageCodes.getMsg(MessageCodes.CD_4007) + "- " + fe.getMessage());
            if(log.isDebugEnabled()){
                log.debug("Unable to connect to ftp. url : " +
                  url + " >> user : " + user + " >> password : " + password,
fe);
            }
            throw fe;
        }catch(SocketException se){
            ExploitLogger.error(MessageCodes.CD_4007,
MessageCodes.getMsg(MessageCodes.CD_4007) + "- " + se.getMessage());
            if(log.isDebugEnabled()){
                log.debug("Unable to connect to ftp. url : " +
                  url + " >> user : " + user + " >> password : " + password,
se);
            }
            throw new FtpException(FtpException.FTP_CONNECTION_FAILED, se);
        }catch(IOException ie){
            ExploitLogger.error(MessageCodes.CD_4007,
MessageCodes.getMsg(MessageCodes.CD_4007) + "- " + ie.getMessage());
            if(log.isDebugEnabled()){
                log.debug("Unable to login to ftp. url :: " +
                     url + " >> user : " + user + " >> password : " + password,
ie);
            }
            throw new FtpException(FtpException.FTP_CONNECTION_FAILED, ie);
        }catch(Exception e){
                ExploitLogger.error(MessageCodes.CD_4007,
MessageCodes.getMsg(MessageCodes.CD_4007) + "- " + e.getMessage());
            if(log.isDebugEnabled()){
                log.debug("Unable to connect to ftp. url ::: " +
                  url + " >> user : " + user + " >> password : " + password,
e);
            }
            throw new FtpException(FtpException.FTP_CONNECTION_FAILED, e);
        }
        finally{
                if(log.isDebugEnabled()){
                log.debug("Inside Finally>> success is> "+success);
            }

        }

        // After connection attempt, you should check the reply code to verify
        // success.
        if(log.isDebugEnabled()){
            log.debug("Reply code for connecting to ftp >>>" +
ftpClient.getReplyCode() + " " + ftpClient.getReplyString());
        }
        return success;
    }


-- 
Configure bugmail: https://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to