I have many users on my web site (20000-60000 per day), which is a download site for mobile files. I have remote access to my server (windows server 2008-R2).
I\'ve
In your code where you run the stored procedure you should have something like this:
SqlCommand c = new SqlCommand(...)
//...
Add such a line of code:
c.CommandTimeout = 0;
This will wait as much time as needed for the operation to complete.
We've had hard times on Timeout expired/max pool reached
Sqlexception
. As a workarround and to prevent restarting the server or the service we modify the MAX SERVER MEMORY
variable in SQL Server (either through SQL Managment Studio or T-SQL):
DECLARE @maxMem INT = 3000 --Max. memory for SQL Server instance in MB
EXEC sp_configure 'show advanced options', 1
RECONFIGURE
This temporarily fixes the issue until it happens again. In our case we suspect that it has to do with connection leaks at app level.
TLDR:
I have often encountered this error for various reasons and have had various solutions, including:
I have issue with large calculation in sp_foo that take large time so i fixed
with this little bit code
public partial class FooEntities : DbContext
{
public FooEntities()
: base("name=FooEntities")
{
this.Configuration.LazyLoadingEnabled = false;
// Get the ObjectContext related to this DbContext
var objectContext = (this as IObjectContextAdapter).ObjectContext;
// Sets the command timeout for all the commands
objectContext.CommandTimeout = 380;
}
You could set the CommandTimeout
property of the SQL Command to allow for the long running SQL transaction.
You might also need to look at the SQL Query that is causing the timeout.
I encountered this error recently and after some brief investigation, found the cause to be that we were running out of space on the disk holding the database (less than 1GB).
As soon as I moved out the database files (.mdf and .ldf) to another disk on the same server (with lots more space), the same page (running the query) that had timed-out loaded within three seconds.
One other thing to investigate, while trying to resolve this error, is the size of the database log files. Your log files just might need to be shrunk.