我的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..
我搜索了stackoverflow,发现了一些有关C#超时的信息以及与此相关的一些错误。
但是Microsoft确实不能解决该问题吗?解决这个问题太难了吗?
最佳答案
这听起来像命令通道上的TCP超时。由于不活动,TCP堆栈启动了断开连接。为了防止这种情况,客户端需要发送所谓的保持活动信号。对于FTP,使用NOOP命令。我不确定您是否可以使用.NET Framework的内置FTPclient来完成此操作。