3

I am getting the below error in my Azure website and am scrambling to fix it:

Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reached.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code. 

Exception Details: System.InvalidOperationException: Timeout expired.  The timeout period elapsed prior to obtaining a connection from the pool.  This may have occurred because all pooled connections were in use and max pool size was reached.

How can I reset the pool or increase it?

4 Answers 4

4

You can increase the SQL Connection Pool in Azure the same was as any other database. By default you get 100 connections. If you don't have that many users on your system you may want to check that you are closing/disposing connections when they're no longer in use.

connectionString="Server=XXX;Database=XXX;User Id=XXX;password=XXX;
    connection timeout=0;Max Pool Size = 500;Pooling = True"
0

You can run a startup command to change the app pool idle timeout. Run something like this from a cmd file called from a Startup task (this example disables timeout):

%windir%\system32\inetsrv\appcmd set config -section:applicationPools -applicationPoolDefaults.processModel.idleTimeout:00:00:00

Using a similar technique, you can recycle the app pool after hitting a certain memory threshold (see this article)

0

Adjust your connection string config like Max Pool Size = 500; in web.config to match your current Azure SQL database tier max connections

For more info about each Azure SQL Tier resource limitations: https://azure.microsoft.com/en-us/documentation/articles/sql-database-resource-limits/

1
  • What are my max connections? Max concurrent sessions or Max concurrent workers (requests)?
    – mslot
    Aug 7, 2019 at 15:06
-3

SqlConnection.ClearAllPools(); Add this before opening a new connection with database.

1

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .