Fix "transport-level error...request to"
作者:techmango 日期:2010-03-11
最近, 公司内部的数据管理系统频繁出现了"A transport-level error has occurred when sending the request to the server..."的SqlServer数据库异常. 由于以前极少出现这种情况, 现在一下子出现许多,领导就怀疑我们程序员是否改动代码. 其实我们什么都没有改, 我们经过努力地查找终于找到了问题的真正原因: 这全都是因为公司的扩长,服务器数量极速增加, 出现了带宽不足,防火墙对数据包的特殊处理(压包解包)或其它别的网络问题导致了SQL Server数据库端的连接自动失效了,但是ADO.net仍然认为这些连接是有效的,程序再继续执行查询就抛出上述的异常了.
现在问题出在SQL的连接上了.而且是过期的连接影响了程序正常的执行.知道了问题的根源,解决它就是不问题了.
方法就是我们可以通过调用连接对象的ClearPoool方法来清除在连接池中是失效的连接,也可以调用SqlConnection.ClearAllPools()方法来清理所有连接的连接池.
就这样,这个烦人的问题被迎刃而解了.
--------------------
Recently, our internal data management system of company usually occur an special SqlServer exception like this:"A transport-level error has occurred when sending the request to the server...". this issue was seldom appear before, now so many this type of issue jump out, so our leader doubt our programer did some incorrect modfications. But, actually we didn't do anything in code, so we try our best to dig out it, eventally we found it: This might be caused by internal netword issue, because that extend of our company, server amount increase with high spead, and data package were zip and extracted, or other netword issue.so these made connect automatically be invalid in Sql server, but program sitll consider it as valid, and continue to query data, so above exception happen.
Now we know the issue is exist on SQL connection,and the overdue connection affect program to excute query normally, so it is not hard to be solved.
The best way is we can call ClearPoool method in the object in ADO.NET to clear these invalid connections in pool, also we can use SqlConnection.ClearAllPools() method to clear all of connections.
At last, this boring issue was solved.
文章来自: 本站原创
Tags: SqlServer ADO.NET ClearAllPools
上一篇
下一篇
