有时在 System.Data.ProviderBase.DbConnectionPool.GetConnection(DbConnection owningObject) 处超时过期(...)

发布于 2024-12-03 07:17:24 字数 1599 浏览 0 评论 0原文

我的网站大部分时间都工作正常,但有时会出现超时过期错误,并且在 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 SELECTs 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

失与倦" 2024-12-10 07:17:24

ADO.NET 中有两个主要的 Timeout 属性。

  1. 连接超时。可以通过在Connection String中设置Connection对象的ConnectionTimeout属性来解决。
  2. 数据访问超时(命令对象)。您可以将 CommandTimeout 属性设置为 Command 对象。我建议您将 CommandTimeOut 属性设置为更大的值。试试这个。请让我知道这是否可以解决这个问题。如果您还有任何疑问,请随时告诉我。

There are two main Timeout property in ADO.NET.

  1. Connection Timeout for Connection. It could be solved by setting ConnectionTimeout property of Connection object in Connection String.
  2. Timeout for Data access ( Command Object ). You can set CommandTimeout property to Command object. I recommend you set CommandTimeOut property to bigger one value. Try this. Please let me know whether this can handle this problem or not. If you have any further questions, please feel free to let me know.
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文