在 ubuntu 14.04 上使用 vsftpd 3.0.2。客户端通常使用标准 FTP 从 Win7 通过 JavaApplet 连接。IE 和 FireFox 都会出现问题。在传输小文件时,客户端不会遇到问题。在传输较大文件时,某些客户端不会“听到”“传输完成”并等待发送下一个文件。它们等待 10 分钟,然后 vsftpd 发出“421 超时”消息。
该小程序上传了 3 个文件,分别是 xxxx.zip、xxxx.xml 和 xxxx.log。xxxx.zip 已完全上传,但随后停滞,而 .xml 和 .log 始终未上传。
该小程序使用相同的用户名/密码,因此来自不同用户的多个连接可以同时使用相同的用户名/密码组合登录。该小程序可防止用户一次打开多个小程序。
其他客户端可以毫无问题地提交 5GB 文件。有什么想法吗?
Vsftpd.log 片段:
Wed Jul 1 00:52:22 2015 [pid 42721] CONNECT: Client "XXX.XXX.XXX.XXX"
Wed Jul 1 00:52:22 2015 [pid 42721] FTP response: Client "XXX.XXX.XXX.XXX", "220 Welcome to CompanyName, Inc. FTP service."
Wed Jul 1 00:52:23 2015 [pid 42721] FTP command: Client "XXX.XXX.XXX.XXX", "USER ftpusername"
Wed Jul 1 00:52:23 2015 [pid 42721] [ftpusername] FTP response: Client "XXX.XXX.XXX.XXX", "331 Please specify the password."
Wed Jul 1 00:52:23 2015 [pid 42721] [ftpusername] FTP command: Client "XXX.XXX.XXX.XXX", "PASS <password>"
Wed Jul 1 00:52:23 2015 [pid 42719] [ftpusername] OK LOGIN: Client "XXX.XXX.XXX.XXX"
Wed Jul 1 00:52:23 2015 [pid 42724] [ftpusername] FTP response: Client "XXX.XXX.XXX.XXX", "230 Login successful."
Wed Jul 1 00:52:23 2015 [pid 42724] [ftpusername] FTP command: Client "XXX.XXX.XXX.XXX", "TYPE I"
Wed Jul 1 00:52:23 2015 [pid 42724] [ftpusername] FTP response: Client "XXX.XXX.XXX.XXX", "200 Switching to Binary mode."
Wed Jul 1 00:52:25 2015 [pid 42724] [ftpusername] FTP command: Client "XXX.XXX.XXX.XXX", "SIZE 202718.zip"
Wed Jul 1 00:52:25 2015 [pid 42724] [ftpusername] FTP response: Client "XXX.XXX.XXX.XXX", "550 Could not get file size."
Wed Jul 1 00:52:25 2015 [pid 42724] [ftpusername] FTP command: Client "XXX.XXX.XXX.XXX", "PWD"
Wed Jul 1 00:52:25 2015 [pid 42724] [ftpusername] FTP response: Client "XXX.XXX.XXX.XXX", "257 "/""
Wed Jul 1 00:52:25 2015 [pid 42724] [ftpusername] FTP command: Client "XXX.XXX.XXX.XXX", "TYPE I"
Wed Jul 1 00:52:25 2015 [pid 42724] [ftpusername] FTP response: Client "XXX.XXX.XXX.XXX", "200 Switching to Binary mode."
Wed Jul 1 00:52:25 2015 [pid 42724] [ftpusername] FTP command: Client "XXX.XXX.XXX.XXX", "PASV"
Wed Jul 1 00:52:25 2015 [pid 42724] [ftpusername] FTP response: Client "XXX.XXX.XXX.XXX", "227 Entering Passive Mode (XXX,XXX,XXX,XXX,200,186)."
Wed Jul 1 00:52:25 2015 [pid 42724] [ftpusername] FTP command: Client "XXX.XXX.XXX.XXX", "SIZE 202718.zip"
Wed Jul 1 00:52:25 2015 [pid 42724] [ftpusername] FTP response: Client "XXX.XXX.XXX.XXX", "550 Could not get file size."
Wed Jul 1 00:52:26 2015 [pid 42724] [ftpusername] FTP command: Client "XXX.XXX.XXX.XXX", "REST 0"
Wed Jul 1 00:52:26 2015 [pid 42724] [ftpusername] FTP response: Client "XXX.XXX.XXX.XXX", "350 Restart position accepted (0)."
Wed Jul 1 00:52:26 2015 [pid 42724] [ftpusername] FTP command: Client "XXX.XXX.XXX.XXX", "STOR 202718.zip"
Wed Jul 1 00:52:26 2015 [pid 42724] [ftpusername] FTP response: Client "XXX.XXX.XXX.XXX", "150 Ok to send data."
Wed Jul 1 01:08:50 2015 [pid 42724] [ftpusername] OK UPLOAD: Client "XXX.XXX.XXX.XXX", "/202718.zip", 508473359 bytes, 504.23Kbyte/sec
Wed Jul 1 01:08:50 2015 [pid 42724] [ftpusername] FTP response: Client "XXX.XXX.XXX.XXX", "226 Transfer complete."
Wed Jul 1 01:18:51 2015 [pid 42724] [ftpusername] FTP response: Client "XXX.XXX.XXX.XXX", "421 Timeout."
Java 小程序日志片段
creating heartbeat
Uploading: 202718.zip
Checking if file already exists on server and what size it is
ftp is NOT null
ftp is connected
UploadPage: FTP Command Sent: ---> SIZE 202718.zip
UploadPage: FTP Command Received: 550 Could not get file size.
UploadPage: FTP Command Sent: ---> PWD
Time to upload the file
UploadPage: FTP Command Received: 257 "/"
UploadPage: FTP Command Sent: ---> TYPE I
UploadPage: FTP Command Received: 200 Switching to Binary mode.
UploadPage: FTP Command Sent: ---> PASV
UploadPage: FTP Command Received: 227 Entering Passive Mode (172,26,157,245,200,186).
UploadPage: FTP Command Sent: ---> SIZE 202718.zip
UploadPage: FTP Command Received: 550 Could not get file size.
UploadPage: FTP Command Sent: ---> REST 0
UploadPage: FTP Command Received: 350 Restart position accepted (0).
UploadPage: FTP Command Sent: ---> STOR 202718.zip
UploadPage: FTP Command Received: 150 Ok to send data.
applet is being stopped
applet is being destroyed
小程序被停止/销毁是因为用户放弃并关闭了包含该小程序的网页。该过程应该继续并上传相关的 .xml 和 .log 文件。
答案1
这通常是由客户端和服务器之间的防火墙/代理或类似的网络组件引起的。
在长时间传输期间,FTP 控制连接上的客户端和服务器之间没有通信,并且防火墙(或类似装置)可能会决定关闭该连接。
检查防火墙配置,看看是否可以为(看似)空闲的连接设置更长的“超时”。