I am facing weird behaviour on IIS 8.5. I am getting an error after I consume my endpoint few times (5-6 times): 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.
My code is written in net core 3.1, and connects to sql server and tries to execute a stored procedure. it works locally with any number of calls. Verified locally that no exception is being thrown.
public int GetCount()
{
int jobCount = 0;
using (SqlCommand com = new SqlCommand("dbo.GETCount", new SqlConnection(this.ConnectionString)) { CommandType = CommandType.StoredProcedure })
{
com.Parameters.Add(new SqlParameter("@jobCount", SqlDbType.Int) { Direction = ParameterDirection.Output });
try
{
com.Connection.Open();
com.ExecuteNonQuery();
jobCount = (int)com.Parameters[0].Value;
}
catch (Exception)
{
throw;
}
finally
{
com.Connection.Close();
}
}
return jobCount;
}
Any suggestions?