超时已过期。之前从池中获取连接超时时间已过。 [英] Timeout expired. The timeout period elapsed prior to obtaining a connection from the pool.

查看:581
本文介绍了超时已过期。之前从池中获取连接超时时间已过。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个应用程序中使用工作的的WebAPI AngularJS 。我有时要花费申请后得到此异常。我使用的的EntityFramework在这个应用



超时。获得从连接之前经过的超时时间池。出现这种情况可能是因为所有池连接均在使用,达到最大池大小。



堆栈跟踪

 在System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(的DbConnection owningConnection,TaskCompletionSource`1重试,DbConnectionOptions USEROPTIONS,DbConnectionInternal和放大器;连接)
↵在System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(的DbConnection outerConnection,DbConnectionFactory connectionFactory的,TaskCompletionSource`1重试,DbConnectionOptions USEROPTIONS)
在System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource` 1重试)
在System.Data.SqlClient.SqlConnection.Open()
在System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(布尔openCondition,的DbConnection storeConnectionToOpen,的DbConnection originalConnection,字符串exceptionCode,字符串attemptedOperation,布尔和放大器; closeStoreConnectionOnFailure)


解决方案

关闭数据库连接(这是非常重要的) 。

 的SqlConnection MyConnection的=新的SqlConnection(ConnectionString中); 

{
conn.Open();
someCall(MyConnection的);
}
终于
{
myConnection.Close();
}

 使用(的SqlConnection MyConnection的=新的SqlConnection(的ConnectionString))
{
myConnection.Open();
someCall(MyConnection的);
}

检查有多少用户连接到数据库并querys超时。检查太多,如果你有很长一段时间执行querys



或许,重复的问题:



How可以解决之间的连接池问题ASP.NET和SQL Server?


I am working on an application using WebApi and AngularJS. I am getting this exception after spending sometime to application. I am using EntityFramework in this app.

"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."

Stack Trace

at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)
↵ at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at System.Data.EntityClient.EntityConnection.OpenStoreConnectionIf(Boolean openCondition, DbConnection storeConnectionToOpen, DbConnection originalConnection, String exceptionCode, String attemptedOperation, Boolean& closeStoreConnectionOnFailure)

解决方案

Close your database connections (it's really important).

SqlConnection myConnection = new SqlConnection(ConnectionString);
try
{
     conn.Open();
     someCall (myConnection);
}
finally
{
     myConnection.Close();                
}

or

using (SqlConnection myConnection = new SqlConnection(ConnectionString))
{
     myConnection.Open();
     someCall(myConnection);
}

Check how many users are connected to your database and the time out for querys. Check too if you have long time executing querys.

Perhaps, duplicate question:

How can I solve a connection pool problem between ASP.NET and SQL Server?

这篇关于超时已过期。之前从池中获取连接超时时间已过。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆