System.Data.Entity.Core.EntityException: The underlying provider failed on Open. —> System.Invalid…

2017/8/15 20:55:21 [AgentPayQuery_205506102_1BBBB] System exception: System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> System.InvalidOperationException: The timeout has expired. The timeout has expired, but the connection has not been obtained from the pool. This may occur because all pooled connections are in use and the maximum pool size has been reached.
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal & amp; connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   in System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   in System.Data.SqlClient.SqlConnection.Open()
   In System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
   at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext)
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass1.<Execute>b__0()
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
   --- End of inner exception stack trace ---
   at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
   at System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection(Boolean shouldMonitorTransactions)
   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass3.<GetResults>b__1()
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()
   at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
   In System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   In System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at PaymentBLL.NewAgentPayBLL.GetByOrderNo(String orderNo, BusinessSystemEnums bizSystem)
   at PaymentService.AgentPayQueryService.QueryPayResult(AgentPayQueryRequestModel reqModel)
2017/8/15 20:55:21 [AgentPayQuery_205506102_1BBBB] Payment center response result: {"status":"FAIL","return_code":"1","return_message":"The underlying provider failed on Open."," return_time":"20170815205521","sign":null}
2017/8/15 20:55:21 [AgentPay_205521542_DADCD] Request payment center parameters: {"amount":"4999900","is_business_acc":"0","order_no":"KB2017081500014631","rec_account_name": "Qian Yong","rec_account_no":"6212261611002875170","rec_bank_no":"ICBC","sign":"7cb0c867ac6315adadc631b94bb41832","third_pay_platform":"10"}
2017/8/15 20:55:36 [AgentPay_205521542_DADCD] System exception: System.Data.Entity.Core.EntityException: The underlying provider failed on Open. ---> System.InvalidOperationException: The timeout has expired. The timeout has expired, but the connection has not been obtained from the pool. This may occur because all pooled connections are in use and the maximum pool size has been reached.
   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal & amp; connection)
   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
   in System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
   in System.Data.SqlClient.SqlConnection.Open()
   In System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)
   at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext)
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.<>c__DisplayClass1.<Execute>b__0()
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
   --- End of inner exception stack trace ---
   at System.Data.Entity.Core.EntityClient.EntityConnection.Open()
   at System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection(Boolean shouldMonitorTransactions)
   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<>c__DisplayClass3.<GetResults>b__1()
   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)
   at System.Data.Entity.Core.Objects.ObjectQuery`1.<System.Collections.Generic.IEnumerable<T>.GetEnumerator>b__0()
   at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()
   In System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)
   In System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)
   at PaymentBLL.NewAgentPayBLL.GetByOrderNo(String orderNo, BusinessSystemEnums bizSystem)
   at PaymentService.AgentPayService.AgentPay(AgentPayRequestModel reqModel)
   In PaymentPlatform.QRCode.HandlerBase.ProcessRequest(HttpContext context)

ref: http://www.cnblogs.com/feiyuhuo/p/5402582.html

Change the size of the connection pool. Add the following code after the connection string:

Enlist=true;Pooling=true;Max Pool Size=300;Min Pool Size=0;Connection Lifetime=300;user id=sa;packet size=1000

The packet size parameter takes any integer value from 512 to 32767