.Net Core Oracle 连接超时

.Net Core Oracle Connection time out

自 8 个月以来,我们发布了带有 oracle 数据库的应用程序 .net 核心,意外返回了请求连接时间,我们没有进行任何部署,也没有使用太多时间,因为我们正在等待第 2 阶段

.Net Core 5 包版本

  1. Microsoft.EntityFrameworkCore >> 5.0.17
  2. Oracle.ManagedDataAccess.Client >> 3.21.61
  3. Oracle.EntityFrameworkCore >> 5.21.61

我们尝试了以下方法:

一些注意事项:

下面的日志:

{ "time": "2022-05-13 00:28:40.8846", "level": "ERROR(Microsoft.EntityFrameworkCore.Database.Connection)", "url": "http:\/\/dedportal.uaqgov.ae\/api\/Activity\/ActivityListAll", "actionName": "ActivityListAll", "Message": "An error occurred using the connection to database '' on server host\/service name'." },


{ "time": "2022-05-13 00:28:40.9270", "level": "ERROR(Microsoft.EntityFrameworkCore.Infrastructure)", "url": "http:\/\/dedportal.uaqgov.ae\/api\/Activity\/ActivityListAll", "actionName": "ActivityListAll", "Message": "1443-10-12 00:28:40.923393 ThreadID:4   (ERROR)   OracleExecutionStrategy.ExecuteAsync() :  Oracle.ManagedDataAccess.Client.OracleException (0x80004005): Connection request timed out
  at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
  at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
  at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, OracleConnection connRefForCriteria)
  at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
  at System.Data.Common.DbConnection.OpenAsync(CancellationToken cancellationToken)\r\n--- End of stack trace from previous location ---
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
  at Oracle.EntityFrameworkCore.Storage.Internal.OracleRelationalCommandBuilderFactory.OracleRelationalCommandBuilder.OracleRelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
  at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(DbContext _, Boolean result, CancellationToken cancellationToken)
  at Oracle.EntityFrameworkCore.Storage.Internal.OracleExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)" },



{ "time": "2022-05-13 00:28:40.9660", "level": "ERROR(Microsoft.EntityFrameworkCore.Query)", "url": "http:\/\/dedportal.uaqgov.ae\/api\/Activity\/ActivityListAll", "actionName": "ActivityListAll", "ExceptionType": "Oracle.ManagedDataAccess.Client.OracleException", "ExceptionMessage": "Connection request timed out", "StackTrace": "   at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
  at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
  at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, OracleConnection connRefForCriteria)
  at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
  at System.Data.Common.DbConnection.OpenAsync(CancellationToken cancellationToken)\r\n--- End of stack trace from previous location ---
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
  at Oracle.EntityFrameworkCore.Storage.Internal.OracleRelationalCommandBuilderFactory.OracleRelationalCommandBuilder.OracleRelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
  at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(DbContext _, Boolean result, CancellationToken cancellationToken)
  at Oracle.EntityFrameworkCore.Storage.Internal.OracleExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
  at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()", "Message": "An exception occurred while iterating over the results of a query for context type 'UAQDED.Infrastructure.DB.DBContext.ModelContext'.\r\nOracle.ManagedDataAccess.Client.OracleException (0x80004005): Connection request timed out
  at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
  at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, OracleConnection connRefForCriteria, String affinityInstanceName, Boolean bForceMatch)
  at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, OracleConnection connRefForCriteria)
  at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
  at System.Data.Common.DbConnection.OpenAsync(CancellationToken cancellationToken)\r\n--- End of stack trace from previous location ---
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenInternalAsync(Boolean errorsExpected, CancellationToken cancellationToken)
  at Microsoft.EntityFrameworkCore.Storage.RelationalConnection.OpenAsync(CancellationToken cancellationToken, Boolean errorsExpected)
  at Oracle.EntityFrameworkCore.Storage.Internal.OracleRelationalCommandBuilderFactory.OracleRelationalCommandBuilder.OracleRelationalCommand.ExecuteReaderAsync(RelationalCommandParameterObject parameterObject, CancellationToken cancellationToken)
  at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.InitializeReaderAsync(DbContext _, Boolean result, CancellationToken cancellationToken)
  at Oracle.EntityFrameworkCore.Storage.Internal.OracleExecutionStrategy.ExecuteAsync[TState,TResult](TState state, Func`4 operation, Func`4 verifySucceeded, CancellationToken cancellationToken)
  at Microsoft.EntityFrameworkCore.Query.Internal.SingleQueryingEnumerable`1.AsyncEnumerator.MoveNextAsync()" },

我们解决了这个问题,我们的扫描侦听器似乎有问题我使用了数据库节点的 IP,它正在工作。