有时在 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) 处超时过期(...)
我的网站大部分时间都工作正常,但有时会出现超时过期错误,并且在 1-15 分钟内无法执行任何操作。第一次发生错误时,它是:
The timeout period elapsed prior to completion of the operation or the server is not responding.
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) (...)
之后,如果我尝试刷新页面,我不断收到:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
(...).
我使用的每个连接都是 SqlDataSource
,或者在如下代码中打开:
SqlConnection myConnection = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Faktury_RebuildConnectionString"].ToString());
SqlCommand myCommand = new SqlCommand("Command String", myConnection);
try{
myConnection.Open();
somecodehere()
}
finally
{
if (myConnection != null)
{
myConnection.Close();
}
}
我的连接字符串在哪里web.config
中的内容为 Data Source=xxx\;Initial Catalog=xxx;User ID=xxx;Password=xxx;Max Pool Size=100;
。
我尝试关闭池化,但没有帮助。我检查了每个连接是否都已正确处理,确实如此。所有SELECT
都很好 - 意味着它们不需要太多时间。特别是当应用程序正常工作时我可以看到这一点。
当我离开网站一段时间(15 - 60 分钟)并首次再次进入时,也会出现此错误;然后我需要做的就是刷新它,然后它就可以正常工作了。
出现此错误时,SQL Server 可以正常工作,而其他使用大部分相同选择查询的网站也可以正常工作。
有人建议那里可能出了什么问题吗?我已经没有主意了。
编辑: 这对于至少在闲置较长时间并让这一次超时过期后不必刷新页面是有用的。
My website works fine most of the time, but sometimes I get timeout expired errors and can't do anything for 1-15 minutes. When error occurs for first time it is:
The timeout period elapsed prior to completion of the operation or the server is not responding.
at System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) (...)
And after that, if I try to refresh page I keep getting:
Timeout expired. The timeout period elapsed prior to completion of the operation or the server is not responding. at System.Data.SqlClient.SqlInternalConnection.OnError(SqlException exception, Boolean breakConnection)
at System.Data.SqlClient.TdsParser.ThrowExceptionAndWarning(TdsParserStateObject stateObj)
(...).
Every connection that I use is either SqlDataSource
, or opened in code like this:
SqlConnection myConnection = new System.Data.SqlClient.SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["Faktury_RebuildConnectionString"].ToString());
SqlCommand myCommand = new SqlCommand("Command String", myConnection);
try{
myConnection.Open();
somecodehere()
}
finally
{
if (myConnection != null)
{
myConnection.Close();
}
}
Where my connection string in web.config
is Data Source=xxx\;Initial Catalog=xxx;User ID=xxx;Password=xxx;Max Pool Size=100;
.
I tried to turn off pooling and it didn't help. I checked if every connection is handled properly and it is. All SELECT
s are good - means they don't take much time. Especially I can see that when application is working properly.
This error also occurs when I leave my site for some time (15 - 60 min) and enter it again for first time; then all I need to do is refresh it and it works fine then.
In times of this error SQL Server works fine and other website using mostly same select queries works fine.
Does anybody have suggestion what may be wrong there? I've run out of ideas.
Edit:
It would be useful to at least not having to refresh page after being idle for longer time and getting this one time timeout expired.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
ADO.NET 中有两个主要的 Timeout 属性。
There are two main Timeout property in ADO.NET.