You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@commons.apache.org by "Marco Campelo (JIRA)" <ji...@apache.org> on 2007/01/03 17:13:27 UTC
[jira] Commented: (NET-91) commons.net.FTPClient hangs on
disconnect or logout
[ https://issues.apache.org/jira/browse/NET-91?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_12461987 ]
Marco Campelo commented on NET-91:
----------------------------------
It is easy to reproduce this issue.
While you are transmitting a file to the FTP server, disconnect your FTP Server from the network.
It will generate the CopyStreamException after around 9 minutes which I believe is the default timeout.
At this moment, if you try to logout from the FTP Server, your java code will stay in deadlock and will never end.
I already tried to test if the ftp is connected using the isConnected method but it always returns true.
> commons.net.FTPClient hangs on disconnect or logout
> ---------------------------------------------------
>
> Key: NET-91
> URL: https://issues.apache.org/jira/browse/NET-91
> Project: Commons Net
> Issue Type: Bug
> Environment: Operating System: All
> Platform: PC
> Reporter: Joe
>
> By repetitively calling
> try {
>
> // connect and login to the FTP server
> ftpc.connect(getPropertyFromEnv("FTP_SERVER"));
>
> ftpc.login(getPropertyFromEnv("USERNAME"), getPropertyFromEnv
> ("PASSWORD")); //technically we may have to break this into 2 blocks see
> examples
> // After connection attempt, check the reply code to verify success.
> reply = ftpc.getReplyCode();
> response = ftpc.getReplyString();
> if(!FTPReply.isPositiveCompletion(reply)) {
> System.err.println("FTP server refused connection or login.");
> killFTP(ftpc);
> ftpc = null;
> }
> } catch(IOException e) {
> System.err.println("Can't connect or login to server, reply
> = "+reply+ " response = " + response);
> killFTP(ftpc);
> ftpc = null;
> }
> and then
> if (ftpc.isConnected()) {
> try {
> ftpc.logout();
> } catch (Exception e) { // do nothing
> System.out.println("Exception in ftpc.logout()");
> }
> try {
> ftpc.disconnect();
> } catch (Exception e) { // do nothing
> System.out.println("Exception in ftpc.disconnect()");
> }
> }
> one of the two bottom calls hangs and I'm assuming that it's in an infinite
> loop waiting for something that the server isn't sending. We try and hook to
> a Linux FTP server, and Windows FTP server and 99.99 % of the time it works,
> but every once in a while, it hangs and we have to kill the FTP daemon. After
> doing that everything works again!!!
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: https://issues.apache.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org