Our Products:   CompleteFTP  edtFTPnet/Free  edtFTPnet/PRO  edtFTPj/Free  edtFTPj/PRO
0 votes
12.1k views
in Java FTP by (160 points)
I recently downloaded your FTP package to replace jakarta-net because I wanted to include a progress monitor for long running downloads. It seems to work fine on Windows XP but when I test on W98 it hangs at the very end of the download. Here is what I have:


FTPClient ftp = new FTPClient(server, 21);
ftp.setConnectMode(FTPConnectMode.PASV);
ftp.login(user, password);
log.append("\nDownloading to " + tmpOutput.getCanonicalFile());
log.setCaretPosition(log.getText().length());

// monitor transfer progress
ftp.setProgressMonitor(new ProgressMonitor(fileSize), (fileSize / 100) + 1);
ftp.setType(FTPTransferType.BINARY);
progressBar.setIndeterminate(false);
progressBar.setVisible(true);

// Download the file
ftp.get(new FileOutputStream(tmpOutput), this.file);

log.append("\nDownload complete.");
ftp.quit();
...
/**
* @see com.enterprisedt.net.ftp.FTPProgressMonitor#bytesTransferred(long)
*/
public void bytesTransferred(long count) {
try {
percentComplete += 1;

float completion = ((((System.currentTimeMillis() - startTime) / percentComplete) * (100
- percentComplete)) / 1000F);
float minutes = completion / 60F;
float seconds = completion % 60F;

if (seconds >= 60) {
seconds -= 60;
minutes += 1;
}

progressBar.setValue(percentComplete);
progressBar.setString(new DecimalFormat("####0").format(minutes) + ":"
+ new DecimalFormat("00").format(seconds) + " to completion");
}
catch (Throwable t) {
log.append("\nError \"" + t.getLocalizedMessage()
+ "\" occured monitoring download.");
}
}


In this case the file looks like it is completely downloaded (however it is two bytes bigger than the original) and the log line after the ftp.get never runs.

Thanks for any help,

David Morris

7 Answers

0 votes
by (140 points)
I do have the same problem when using PASV mode. I'm on Win XP though.

When I remove the call to set PASV mode things work always fine for me.

I'm using JDK 1.4.2
0 votes
by
Are you using the same JDK on both machines?

I recently downloaded your FTP package to replace jakarta-net because I wanted to include a progress monitor for long running downloads. It seems to work fine on Windows XP but when I test on W98 it hangs at the very end of the download.
0 votes
by (160 points)
Yes, they are the same JDK - 1.4.2_02. I tried with another smaller file (about 1.5M) and it seems to work fine. The larger one (about 42M) consistently fails. I figured out how to get Sun's FTP server to run in passive mode and display a progress bar and made the FTP server configurable in my program. I will let you know if Sun has the same problem.

Thanks,

David Morris
0 votes
by
Thank you for your help.

The hang appears to be related to FTP on W98 and not your package. I tried with and without passive -- same result. Works fine on W2000 and XP. This is frustrating because the alternatives require significanly more infrastructure than FTP. Before doing that I will try chunking up the download into smaller pieces. I couldn't find it but does EDT FTP support resumption of download?
0 votes
by
Currently edtFTP doesn't support resume. I'll make a note to consider adding this feature.

Thank you for your help.

The hang appears to be related to FTP on W98 and not your package. I tried with and without passive -- same result. Works fine on W2000 and XP. This is frustrating because the alternatives require significanly more infrastructure than FTP. Before doing that I will try chunking up the download into smaller pieces. I couldn't find it but does EDT FTP support resumption of download?
0 votes
by (440 points)
David,

I am having trouble figuring out how to get the progress bar to update if it originates in a different class than that of the progress monitor. Any suggestoins or example code would be greatly appreciated.
0 votes
by (162k points)
Take a look at my reply in this thread:

http://www.enterprisedt.com/forums/viewtopic.php?t=87

Hopefully that helps

David,

I am having trouble figuring out how to get the progress bar to update if it originates in a different class than that of the progress monitor. Any suggestoins or example code would be greatly appreciated.

Categories

...