2008年11月19日星期三

An existing connection was forcibly closed by the remote host

问题描述:
========
前端WEB应用程序报错:
System.Data.SqlClient.SqlException: A transport-level error has occurred when sending the request to the server. (provider: TCP Provider, error: 0 - An existing connection was forcibly closed by the remote host.)

原因描述:
========
一般情况下这个报错信息是由于您数据库服务器是Windows Server 2003 SP1之后的版本,由于在Windows Server 2003 SP1和SP2中添加了一个新的功能,通过将处理TCP/IP请求的任务下放给网卡,减少了并发TCP/IP连接服务器的队列大小。而这个功能可以在网络负载大的情况下,系统可能就会无法正确地识别有效的TCP/IP链接。

解决步骤:
========
所以我建议您尝试如下步骤,禁用掉Windows 2003的这个功能:

首先,请务必备份您的注册表。

步骤一:
1. 在装有SQL 的服务器上打开注册表
2. 找到注册表项:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
3. 在右边查找注册表值SynAttackProtect,如果找到,请确认其值为0,如果不是,请改为0
4. 如果第3步中没有发现这个值,请手动新建一个DWORD值,取名为SynAttackProtect,修改值为0
5. 退出注册表,重新启动服务器

步骤二:
1. 在装有SQL 的服务器上打开注册表
2. 找到注册表项:HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters
3. 在右边手动新建一个DWORD值,取名为EnableRSS,修改值为0
4. 退出注册表,重新启动服务器

步骤三:
1. 点击开始->运行->输入cmd->回车
2. 在命令行中输入"Netsh int ip set chimney DISABLED" (不包含引号),确认其成功完成
3. 观察问题是否还存在

相关文档:
========

http://support.microsoft.com/kb/945977


http://support.microsoft.com/default.aspx?scid=kb;en-us;912222


http://support.microsoft.com/kb/942861/en-us