Периодическая проблема «Базовый поставщик не удалось открыть» в Entity Framework: что происходит?C#

Место общения программистов C#
Ответить
Anonymous
 Периодическая проблема «Базовый поставщик не удалось открыть» в Entity Framework: что происходит?

Сообщение Anonymous »

У меня есть подключение к базе данных SQL Server из Службы приложений в Azure (с выделенной виртуальной сетью), которое в какой-то момент (момент X) начинает становиться странным и прекращает каждое последующее подключение примерно на 1 час.Вот полное исключение, которое я получаю для каждого нового соединения, которое я запускаю после момента X:

Код: Выделить всё

{
"ClassName": "System.Data.Entity.Core.EntityException",
"Message": "The underlying provider failed on Open.",
"Data": null,
"InnerException": {
"Errors": [{
"Source": ".Net SqlClient Data Provider",
"Number": 5,
"State": 0,
"Class": 20,
"Server": "",
"Message": "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)",
"Procedure": null,
"LineNumber": 0
}
],
"ClientConnectionId": "00000000-0000-0000-0000-000000000000",
"ClassName": "System.Data.SqlClient.SqlException",
"Message": "A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections.  (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)",
"Data": {
"HelpLink.ProdName": "Microsoft SQL Server",
"HelpLink.EvtSrc": "MSSQLServer",
"HelpLink.EvtID": "5",
"HelpLink.BaseHelpUrl": "http://go.microsoft.com/fwlink",
"HelpLink.LinkId": "20476"
},
"InnerException": {
"NativeErrorCode": 5,
"ClassName": "System.ComponentModel.Win32Exception",
"Message": "Access is denied",
"Data": null,
"InnerException": null,
"HelpURL": null,
"StackTraceString": null,
"RemoteStackTraceString": null,
"RemoteStackIndex": 0,
"ExceptionMethod": null,
"HResult": -2147467259,
"Source": null,
"WatsonBuckets": null
},
"HelpURL": null,
"StackTraceString": "   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, UInt32 waitForMultipleObjectsTimeout, Boolean allowCreate, Boolean onlyOneCheckConnection, DbConnectionOptions userOptions, DbConnectionInternal& connection)\r\n   at System.Data.ProviderBase.DbConnectionPool.TryGetConnection(DbConnection owningObject, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal& connection)\r\n   at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)\r\n   at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)\r\n   at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)\r\n   at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)\r\n   at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)\r\n   at System.Data.SqlClient.SqlConnection.Open()\r\n   at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.c.b__13_0(DbConnection t, DbConnectionInterceptionContext c)\r\n   at System.Data.Entity.Infrastructure.Interception.InternalDispatcher`1.Dispatch[TTarget,TInterceptionContext](TTarget target, Action`2 operation, TInterceptionContext interceptionContext, Action`3 executing, Action`3 executed)\r\n   at System.Data.Entity.Infrastructure.Interception.DbConnectionDispatcher.Open(DbConnection connection, DbInterceptionContext interceptionContext)\r\n   at System.Data.Entity.Core.EntityClient.EntityConnection.b__55_0()\r\n   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.c__DisplayClass2_0.b__0()\r\n   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)\r\n   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute(Action operation)\r\n   at System.Data.Entity.Core.EntityClient.EntityConnection.Open()",
"RemoteStackTraceString": null,
"RemoteStackIndex": 0,
"ExceptionMethod": "8\nTryGetConnection\nSystem.Data, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\nSystem.Data.ProviderBase.DbConnectionPool\nBoolean TryGetConnection(System.Data.Common.DbConnection, UInt32, Boolean, Boolean, System.Data.Common.DbConnectionOptions, System.Data.ProviderBase.DbConnectionInternal ByRef)",
"HResult": -2146232060,
"Source": ".Net SqlClient Data Provider",
"WatsonBuckets": null
},
"HelpURL": null,
"StackTraceString": "    at System.Data.Entity.Core.EntityClient.EntityConnection.Open()\r\n   at System.Data.Entity.Core.Objects.ObjectContext.EnsureConnection(Boolean shouldMonitorTransactions)\r\n   at System.Data.Entity.Core.Objects.ObjectContext.ExecuteInTransaction[T](Func`1 func, IDbExecutionStrategy executionStrategy, Boolean startLocalTransaction, Boolean releaseConnectionOnSuccess)\r\n   at System.Data.Entity.Core.Objects.ObjectQuery`1.c__DisplayClass41_0.b__0()\r\n   at System.Data.Entity.SqlServer.DefaultSqlExecutionStrategy.Execute[TResult](Func`1 operation)\r\n   at System.Data.Entity.Core.Objects.ObjectQuery`1.GetResults(Nullable`1 forMergeOption)\r\n   at System.Data.Entity.Core.Objects.ObjectQuery`1.b__31_0()\r\n   at System.Data.Entity.Internal.LazyEnumerator`1.MoveNext()\r\n   at System.Linq.Enumerable.FirstOrDefault[TSource](IEnumerable`1 source)\r\n   at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.c__14`1.b__14_1(IEnumerable`1 sequence)\r\n   at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.ExecuteSingle[TResult](IEnumerable`1 query, Expression queryRoot)\r\n   at System.Data.Entity.Core.Objects.ELinq.ObjectQueryProvider.System.Linq.IQueryProvider.Execute[TResult](Expression expression)\r\n   at System.Data.Entity.Internal.Linq.DbQueryProvider.Execute[TResult](Expression expression)\r\n   at System.Linq.Queryable.FirstOrDefault[TSource](IQueryable`1 source)\r\n   at PRJAPI.Helpers.MyHelper.LoadData(String dataNumber) in C:\\Users\\source\\repos\\Project\\MySolution\\PRJ\\PRJAPI\\Helpers\\MyHelper.cs:line 398",
"RemoteStackTraceString": null,
"RemoteStackIndex": 0,
"ExceptionMethod": "8\nOpen\nEntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\nSystem.Data.Entity.Core.EntityClient.EntityConnection\nVoid Open()",
"HResult": -2146233087,
"Source": "EntityFramework",
"WatsonBuckets": null
}
Что я вижу (но, возможно, это ложное срабатывание), брандмауэр между приложением и SQL Server иногда отбрасывает один TCP-пакет в ответ от SQL Server; не уверен, актуально это или нет.
Дело в том, что я могу принять разрыв одного соединения (я мог бы установить опрос и повторную попытку), но оно блокирует следующее соединение для такой час, это вообще не имеет смысла?
Кроме того: во время этого «простоя» я могу получить доступ к удаленной БД, используя те же учетные данные (или то же приложение с другого сервера), так что "Доступ запрещен" - это очень странно.

Подробнее здесь: https://stackoverflow.com/questions/785 ... y-framewor
Ответить

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

Вернуться в «C#»