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.