最近几天,我们经常在网站上看到这样的错误信息:
“超时过期。超时时间
在获取
来自池的连接。这可能
已经发生是因为全部池化了吗
连接正在使用,马克斯泳池
规模达到了。”
我们已经有一段时间没有更改代码中的任何内容了。我修改了代码以检查未关闭的打开连接,但发现一切正常。
我怎么解决这个问题?
我需要编辑这个池吗?
如何编辑此池的最大连接数?
高流量网站的推荐值是多少?
更新:
我需要在IIS中编辑一些东西吗?
更新:
我发现活动连接的数量在15到31之间,我发现在SQL server中配置的最大允许连接数超过3200个连接,是31太多了还是我应该在ASP中编辑一些东西。网络配置?
你也可以尝试一下,解决超时问题:
如果你没有在你的webconfig中添加httpRuntime,在<system中添加。网络>标记
<sytem.web>
<httpRuntime maxRequestLength="20000" executionTimeout="999999"/>
</system.web>
and
像这样修改你的连接字符串;
<add name="connstring" connectionString="Data Source=DSourceName;Initial Catalog=DBName;Integrated Security=True;Max Pool Size=50000;Pooling=True;" providerName="System.Data.SqlClient" />
最后使用
try
{...}
catch
{...}
finaly
{
connection.close();
}
您已经泄漏了代码上的连接。您可以尝试使用using来证明您正在关闭它们。
using (SqlConnection sqlconnection1 = new SqlConnection(“Server=.\\SQLEXPRESS ;Integrated security=sspi;connection timeout=5”))
{
sqlconnection1.Open();
SqlCommand sqlcommand1 = sqlconnection1.CreateCommand();
sqlcommand1.CommandText = “raiserror (‘This is a fake exception’, 17,1)”;
sqlcommand1.ExecuteNonQuery(); //this throws a SqlException every time it is called.
sqlconnection1.Close(); //Still never gets called.
} // Here sqlconnection1.Dispose is _guaranteed_
https://blogs.msdn.microsoft.com/angelsb/2004/08/25/connection-pooling-and-the-timeout-expired-exception-faq/