0

我的 ftp 上传需要几个小时,例如 10 小时。

在 1 小时 48 分 25 秒(大约!)(= ~ 108 分钟)后,mysql 服务器、proftpd 服务器或 c# 断开与客户端的连接......(我尝试了 5 次)

或者哪个软件负责?

C#代码:

FtpWebRequest req = (FtpWebRequest)WebRequest.Create("ftp://192.168.1.3/test-file.zip");
req.Credentials = new NetworkCredential("username", "password");
req.UsePassive = true;
req.EnableSsl = true;
req.UseBinary = true;
// Upload per req.GetRequestStream .Write

Proftpd-配置“超时”:

TimeoutIdle             1200
TimeoutNoTransfer       600
TimeoutStalled          600

Proftpd 日志:

Oct 20 09:15:43 WD-NAS proftpd[2700] WD-NAS.fritz.box (patrick.fritz.box[192.168.1.2]): FTP session opened.
Oct 20 09:15:51 WD-NAS proftpd[2700] WD-NAS.fritz.box (patrick.fritz.box[192.168.1.2]): Preparing to chroot to directory '/var/www/files'
Oct 20 09:15:51 WD-NAS proftpd[2700] WD-NAS.fritz.box (patrick.fritz.box[192.168.1.2]): USER username: Login successful.
Oct 20 11:04:16 WD-NAS proftpd[2700] WD-NAS.fritz.box (patrick.fritz.box[192.168.1.2]): FTP session closed.

MySQL-日志:

Oct 20 09:15:43 mod_sql/4.3[2700]: defaulting to 'mysql' backend
Oct 20 09:15:43 mod_sql/4.3[2700]: backend module 'mod_sql_mysql/4.0.8'
Oct 20 09:15:43 mod_sql/4.3[2700]: backend api    'mod_sql_api_v1'
Oct 20 09:15:43 mod_sql/4.3[2700]: >>> sql_sess_init
Oct 20 09:15:43 mod_sql/4.3[2700]: entering     mysql cmd_defineconnection
Oct 20 09:15:43 mod_sql/4.3[2700]:   name: 'default'
Oct 20 09:15:43 mod_sql/4.3[2700]:   user: 'ftpd'
Oct 20 09:15:43 mod_sql/4.3[2700]:   host: 'localhost'
Oct 20 09:15:43 mod_sql/4.3[2700]:     db: 'ftpd'
Oct 20 09:15:43 mod_sql/4.3[2700]:   port: '3306'
Oct 20 09:15:43 mod_sql/4.3[2700]:    ttl: '0'
Oct 20 09:15:43 mod_sql/4.3[2700]: exiting  mysql cmd_defineconnection
Oct 20 09:15:43 mod_sql/4.3[2700]: connection 'default' successfully established
Oct 20 09:15:43 mod_sql/4.3[2700]: mod_sql engine     : on
Oct 20 09:15:43 mod_sql/4.3[2700]: negative_cache     : off
Oct 20 09:15:43 mod_sql/4.3[2700]: authenticate       : users groups 
Oct 20 09:15:43 mod_sql/4.3[2700]: usertable          : ftpuser
Oct 20 09:15:43 mod_sql/4.3[2700]: userid field       : userid
Oct 20 09:15:43 mod_sql/4.3[2700]: password field     : passwd
Oct 20 09:15:43 mod_sql/4.3[2700]: UID field          : uid
Oct 20 09:15:43 mod_sql/4.3[2700]: GID field          : gid
Oct 20 09:15:43 mod_sql/4.3[2700]: homedir field      : homedir
Oct 20 09:15:43 mod_sql/4.3[2700]: shell field        : shell
Oct 20 09:15:43 mod_sql/4.3[2700]: group table        : ftpgroup
Oct 20 09:15:43 mod_sql/4.3[2700]: groupname field    : groupname
Oct 20 09:15:43 mod_sql/4.3[2700]: grp GID field      : gid
Oct 20 09:15:43 mod_sql/4.3[2700]: grp members field  : members
Oct 20 09:15:43 mod_sql/4.3[2700]: SQLMinUserUID      : 500
Oct 20 09:15:43 mod_sql/4.3[2700]: SQLMinUserGID      : 500
Oct 20 09:15:43 mod_sql/4.3[2700]: SQLDefaultUID      : 65533
Oct 20 09:15:43 mod_sql/4.3[2700]: SQLDefaultGID      : 65533
Oct 20 09:15:43 mod_sql/4.3[2700]: <<< sql_sess_init
Oct 20 09:15:49 mod_sql/4.3[2700]: >>> sql_pre_pass
Oct 20 09:15:49 mod_sql/4.3[2700]: <<< sql_pre_pass
Oct 20 09:15:49 mod_sql/4.3[2700]: >>> cmd_getpwnam
Oct 20 09:15:49 mod_sql/4.3[2700]: entering     mysql cmd_escapestring
Oct 20 09:15:49 mod_sql/4.3[2700]: entering     mysql cmd_open
Oct 20 09:15:49 mod_sql/4.3[2700]: MySQL client version: 5.5.35
Oct 20 09:15:49 mod_sql/4.3[2700]: MySQL server version: 5.5.35-0ubuntu0.12.04.2
Oct 20 09:15:49 mod_sql/4.3[2700]: MySQL connection character set now 'utf8' (from 'UTF-8')
Oct 20 09:15:49 mod_sql/4.3[2700]: connection 'default' opened
Oct 20 09:15:49 mod_sql/4.3[2700]: connection 'default' count is now 2
Oct 20 09:15:49 mod_sql/4.3[2700]: exiting  mysql cmd_open
Oct 20 09:15:49 mod_sql/4.3[2700]: entering     mysql cmd_close
Oct 20 09:15:49 mod_sql/4.3[2700]: connection 'default' count is now 1
Oct 20 09:15:49 mod_sql/4.3[2700]: exiting  mysql cmd_close
Oct 20 09:15:49 mod_sql/4.3[2700]: exiting  mysql cmd_escapestring
Oct 20 09:15:49 mod_sql/4.3[2700]: cache miss for user 'username'
Oct 20 09:15:49 mod_sql/4.3[2700]: entering     mysql cmd_select
Oct 20 09:15:49 mod_sql/4.3[2700]: entering     mysql cmd_open
Oct 20 09:15:49 mod_sql/4.3[2700]: connection 'default' count is now 2
Oct 20 09:15:49 mod_sql/4.3[2700]: exiting  mysql cmd_open
Oct 20 09:15:49 mod_sql/4.3[2700]: query "SELECT userid, passwd, uid, gid, homedir, shell FROM ftpuser WHERE (userid='username') LIMIT 1"
Oct 20 09:15:49 mod_sql/4.3[2700]: entering     mysql cmd_close
Oct 20 09:15:49 mod_sql/4.3[2700]: connection 'default' count is now 1
Oct 20 09:15:49 mod_sql/4.3[2700]: exiting  mysql cmd_close
Oct 20 09:15:49 mod_sql/4.3[2700]: exiting  mysql cmd_select
Oct 20 09:15:49 mod_sql/4.3[2700]: cache miss for user 'username'
Oct 20 09:15:49 mod_sql/4.3[2700]: user 'username' cached
Oct 20 09:15:49 mod_sql/4.3[2700]: + pwd.pw_name  : username
Oct 20 09:15:49 mod_sql/4.3[2700]: + pwd.pw_uid   : 5500
Oct 20 09:15:49 mod_sql/4.3[2700]: + pwd.pw_gid   : 5500
Oct 20 09:15:49 mod_sql/4.3[2700]: + pwd.pw_dir   : /srv/backups/files
Oct 20 09:15:49 mod_sql/4.3[2700]: + pwd.pw_shell : /sbin/nologin
Oct 20 09:15:49 mod_sql/4.3[2700]: <<< cmd_getpwnam
Oct 20 09:15:49 mod_sql/4.3[2700]: >>> cmd_gid2name
Oct 20 09:15:49 mod_sql/4.3[2700]: cache miss for GID '5500'
Oct 20 09:15:49 mod_sql/4.3[2700]: entering     mysql cmd_select
Oct 20 09:15:49 mod_sql/4.3[2700]: entering     mysql cmd_open
Oct 20 09:15:49 mod_sql/4.3[2700]: connection 'default' count is now 2
Oct 20 09:15:49 mod_sql/4.3[2700]: exiting  mysql cmd_open
Oct 20 09:15:49 mod_sql/4.3[2700]: query "SELECT groupname FROM ftpgroup WHERE (gid = 5500) LIMIT 1"
Oct 20 09:15:49 mod_sql/4.3[2700]: entering     mysql cmd_close
Oct 20 09:15:49 mod_sql/4.3[2700]: connection 'default' count is now 1
Oct 20 09:15:49 mod_sql/4.3[2700]: exiting  mysql cmd_close
Oct 20 09:15:49 mod_sql/4.3[2700]: exiting  mysql cmd_select
Oct 20 09:15:49 mod_sql/4.3[2700]: <<< cmd_gid2name
Oct 20 09:15:49 mod_sql/4.3[2700]: >>> cmd_getgroups
Oct 20 09:15:49 mod_sql/4.3[2700]: cache hit for user 'username'
Oct 20 09:15:49 mod_sql/4.3[2700]: cache miss for GID '5500'
Oct 20 09:15:49 mod_sql/4.3[2700]: entering     mysql cmd_select
Oct 20 09:15:49 mod_sql/4.3[2700]: entering     mysql cmd_open
Oct 20 09:15:49 mod_sql/4.3[2700]: connection 'default' count is now 2
Oct 20 09:15:49 mod_sql/4.3[2700]: exiting  mysql cmd_open
Oct 20 09:15:49 mod_sql/4.3[2700]: query "SELECT groupname FROM ftpgroup WHERE (gid = 5500) LIMIT 1"
Oct 20 09:15:49 mod_sql/4.3[2700]: entering     mysql cmd_close
Oct 20 09:15:49 mod_sql/4.3[2700]: connection 'default' count is now 1
Oct 20 09:15:49 mod_sql/4.3[2700]: exiting  mysql cmd_close
Oct 20 09:15:49 mod_sql/4.3[2700]: exiting  mysql cmd_select
Oct 20 09:15:49 mod_sql/4.3[2700]: entering     mysql cmd_escapestring
Oct 20 09:15:49 mod_sql/4.3[2700]: entering     mysql cmd_open
Oct 20 09:15:49 mod_sql/4.3[2700]: connection 'default' count is now 2
Oct 20 09:15:49 mod_sql/4.3[2700]: exiting  mysql cmd_open
Oct 20 09:15:49 mod_sql/4.3[2700]: entering     mysql cmd_close
Oct 20 09:15:49 mod_sql/4.3[2700]: connection 'default' count is now 1
Oct 20 09:15:49 mod_sql/4.3[2700]: exiting  mysql cmd_close
Oct 20 09:15:49 mod_sql/4.3[2700]: exiting  mysql cmd_escapestring
Oct 20 09:15:49 mod_sql/4.3[2700]: entering     mysql cmd_select
Oct 20 09:15:49 mod_sql/4.3[2700]: entering     mysql cmd_open
Oct 20 09:15:49 mod_sql/4.3[2700]: connection 'default' count is now 2
Oct 20 09:15:49 mod_sql/4.3[2700]: exiting  mysql cmd_open
Oct 20 09:15:49 mod_sql/4.3[2700]: query "SELECT groupname, gid, members FROM ftpgroup WHERE (members = 'username' OR members LIKE 'username,%' OR members LIKE '%,username' OR members LIKE '%,username,%')"
Oct 20 09:15:49 mod_sql/4.3[2700]: entering     mysql cmd_close
Oct 20 09:15:49 mod_sql/4.3[2700]: connection 'default' count is now 1
Oct 20 09:15:49 mod_sql/4.3[2700]: exiting  mysql cmd_close
Oct 20 09:15:49 mod_sql/4.3[2700]: exiting  mysql cmd_select
Oct 20 09:15:49 mod_sql/4.3[2700]: <<< cmd_getgroups
Oct 20 09:15:51 mod_sql/4.3[2700]: >>> cmd_auth
Oct 20 09:15:51 mod_sql/4.3[2700]: entering     mysql cmd_escapestring
Oct 20 09:15:51 mod_sql/4.3[2700]: entering     mysql cmd_open
Oct 20 09:15:51 mod_sql/4.3[2700]: connection 'default' count is now 2
Oct 20 09:15:51 mod_sql/4.3[2700]: exiting  mysql cmd_open
Oct 20 09:15:51 mod_sql/4.3[2700]: entering     mysql cmd_close
Oct 20 09:15:51 mod_sql/4.3[2700]: connection 'default' count is now 1
Oct 20 09:15:51 mod_sql/4.3[2700]: exiting  mysql cmd_close
Oct 20 09:15:51 mod_sql/4.3[2700]: exiting  mysql cmd_escapestring
Oct 20 09:15:51 mod_sql/4.3[2700]: cache hit for user 'username'
Oct 20 09:15:51 mod_sql/4.3[2700]: >>> cmd_check
Oct 20 09:15:51 mod_sql/4.3[2700]: checking password using SQLAuthType 'Crypt'
Oct 20 09:15:51 mod_sql/4.3[2700]: 'Crypt' SQLAuthType handler reports success
Oct 20 09:15:51 mod_sql/4.3[2700]: cache hit for user 'username'
Oct 20 09:15:51 mod_sql/4.3[2700]: <<< cmd_check
Oct 20 09:15:51 mod_sql/4.3[2700]: <<< cmd_auth
Oct 20 09:15:51 mod_sql/4.3[2700]: >>> cmd_getpwnam
Oct 20 09:15:51 mod_sql/4.3[2700]: cache hit for user 'username'
Oct 20 09:15:51 mod_sql/4.3[2700]: <<< cmd_getpwnam
Oct 20 09:15:51 mod_sql/4.3[2700]: >>> log_master (SQLLog_PASS)
Oct 20 09:15:51 mod_sql/4.3[2700]: >>> process_named_query 'updatecount'
Oct 20 09:15:51 mod_sql/4.3[2700]: entering     mysql cmd_escapestring
Oct 20 09:15:51 mod_sql/4.3[2700]: entering     mysql cmd_open
Oct 20 09:15:51 mod_sql/4.3[2700]: connection 'default' count is now 2
Oct 20 09:15:51 mod_sql/4.3[2700]: exiting  mysql cmd_open
Oct 20 09:15:51 mod_sql/4.3[2700]: entering     mysql cmd_close
Oct 20 09:15:51 mod_sql/4.3[2700]: connection 'default' count is now 1
Oct 20 09:15:51 mod_sql/4.3[2700]: exiting  mysql cmd_close
Oct 20 09:15:51 mod_sql/4.3[2700]: exiting  mysql cmd_escapestring
Oct 20 09:15:51 mod_sql/4.3[2700]: entering     mysql cmd_update
Oct 20 09:15:51 mod_sql/4.3[2700]: entering     mysql cmd_open
Oct 20 09:15:51 mod_sql/4.3[2700]: connection 'default' count is now 2
Oct 20 09:15:51 mod_sql/4.3[2700]: exiting  mysql cmd_open
Oct 20 09:15:51 mod_sql/4.3[2700]: query "UPDATE ftpuser SET count=count+1, accessed=now() WHERE userid='username'"
Oct 20 09:15:51 mod_sql/4.3[2700]: entering     mysql cmd_close
Oct 20 09:15:51 mod_sql/4.3[2700]: connection 'default' count is now 1
Oct 20 09:15:51 mod_sql/4.3[2700]: exiting  mysql cmd_close
Oct 20 09:15:51 mod_sql/4.3[2700]: exiting  mysql cmd_update
Oct 20 09:15:51 mod_sql/4.3[2700]: <<< process_named_query 'updatecount'
Oct 20 09:15:51 mod_sql/4.3[2700]: <<< log_master (SQLLog_PASS)
Oct 20 11:04:16 mod_sql/4.3[2700]: entering     mysql cmd_exit
Oct 20 11:04:16 mod_sql/4.3[2700]: entering     mysql cmd_close
Oct 20 11:04:16 mod_sql/4.3[2700]: connection 'default' closed
Oct 20 11:04:16 mod_sql/4.3[2700]: connection 'default' count is now 0
Oct 20 11:04:16 mod_sql/4.3[2700]: exiting  mysql cmd_close
Oct 20 11:04:16 mod_sql/4.3[2700]: exiting  mysql cmd_exit

C# 错误:

2014-10-20 11:04:15 System.Net.WebException: The underlying connection was closed: An unexpected error occurred on a receive..

我搜索了堆栈溢出,发现了一些关于 C# 超时和一些错误的信息。

但是微软真的不能解决这个问题吗?解决问题是不是太难了?

4

1 回答 1

0

这听起来像是命令通道上的 TCP 超时。由于不活动,断开连接由 TCP 堆栈发起。为了防止这种情况,客户端需要发送所谓的保持活动信号。对于 FTP,使用 NOOP 命令。不过,我不确定您是否可以使用 .NET 框架的内置 FTPclient 来做到这一点。

于 2014-10-21T10:40:37.260 回答