我在一台主机上运行了apache服务器,另一台运行了apache ftp客户端。 从客户端代码运行下载时,我看到下载大约150 MB后,下载速度急剧下降。
注意:我正在尝试下载超过2 GB
我尝试在运行ftp客户端的同一台机器上使用filezila下载相同的文件夹,在这种情况下,下载速度要快得多。
所以我想我的FTP客户端mu实现有问题。
任何想法?
低于我的FTPClient下载代码:
try (BufferedOutputStream bufferedOutputStream = new BufferedOutputStream(fos,
ftpConfig.getBufferOutputStreamSize()))
{
InputStream inputStream = client.retrieveFileStream(fileName);
int bufferSize = 1024;
byte[] bytesArray = new byte[bufferSize];
int bytesRead;
while ((bytesRead = inputStream.read(bytesArray)) != -1)
{
bufferedOutputStream.write(bytesArray, 0, bytesRead);
}
result = client.completePendingCommand();
inputStream.close();
bufferedOutputStream.flush();
fos.flush();
}
}
我在客户端日志中注意到以下异常:
Exception of the class java.net.SocketTimeoutException
INFO | jvm 1 | 2017/12/06 11:42:39 | java.net.SocketTimeoutException: Read timed out
INFO | jvm 1 | 2017/12/06 11:42:39 | at java.net.SocketInputStream.socketRead0(Native Method)
INFO | jvm 1 | 2017/12/06 11:42:39 | at java.net.SocketInputStream.socketRead(SocketInputStream.java:127)
INFO | jvm 1 | 2017/12/06 11:42:39 | at java.net.SocketInputStream.read(SocketInputStream.java:182)
INFO | jvm 1 | 2017/12/06 11:42:39 | at java.net.SocketInputStream.read(SocketInputStream.java:152)
INFO | jvm 1 | 2017/12/06 11:42:39 | at java.io.FilterInputStream.read(FilterInputStream.java:144)
INFO | jvm 1 | 2017/12/06 11:42:39 | at java.io.FilterInputStream.read(FilterInputStream.java:118)