I’ve got an asp.net 4 based web application with connection pool issues.
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
At first I thought there was some connection I forgot to close but it doesn’t seem like thats the problem. When I set Pooling=False I can see that all connections are released(by looking in ssms).
Strangely this issue only occurs in our production environment. I tried launching the web application locally and connect it to the production database and then it works fine(releases connections). This makes me think that it has something to do with IIS but I cant figure out what could cause this error. The only difference between the environments is that the application pool is run by NetworkService in dev and an AD-account in prod. Theres no difference in number of users since the site is not launched yet.
I even tried to set Max Pool Size = 10 to provoke the error in our development environment but it still works.
Any ideas?
Update
It looks like we’ve got leaking connections
using (SqlCommand cmd = new SqlCommand())
{
cmd.CommandType = CommandType.Text;
cmd.Connection = ConnectionUtil.CreateNewConnection();
//query code
}
Im guessing the above code only will dispose the SqlCommand but wont close the connection.
Am I right?
I used to see this error when I forgot to close the connection in the Finally block.
Going back to classic ASP, I used to see “errors” when the default database language was set to English, not database default. (This used to throw an exception that couldn’t be caught – at least not in classic ASP)