Skip to Main Content

ODP.NET

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Database not available when the application is started (doesn't auto-recover)

This is a cross-post from https://community.oracle.com/tech/developers/discussion/4490184/unexpected-exception-when-reconnecting-to-database-after-init-without-connection-to-db, because I think it was posted in the wrong forum.
Hi,
I discovered an issue when using an Easy Connect connectionstring that doesn't occur when using a TNS less connectionstring.
The usecase is the following:
Create a little test project containing a single API call that fetches some records from the Oracle database via EF Core (standard ASP.NET and EF Core example code).
Then do the following to get the exception:
If is unplug the network and disable the wifi so that no connection can be made to the Oracle Database
Start the API project (hosted in IIS Express)
Via Swagger or Postman call the API => this will give an exception (completely normal behavior)
Plug the network back in and/or enable to wifi so the database is accessible again
Via Swagger or Postman call the API again => this and every other call keeps returning the same exception
If the connectionstring is switched from Easy Connect to TNS less, the second call doesn't give an exception but returns the expected result.
This is the stacktrace:

Oracle.ManagedDataAccess.Client.OracleException (0x80004005): ORA-12154: TNS:could not resolve the connect identifier specified
 ---> OracleInternal.Network.NetworkException (0x00002F7A): ORA-12154: TNS:could not resolve the connect identifier specified
   at OracleInternal.Network.AddressResolution..ctor(String TNSAlias, SqlNetOraConfig SNOConfig, Hashtable ObTnsHT, Hashtable ObLdpHT, String instanceName, ConnectionOption CO, String ShardingKeyB64, String SuperShardingKeyB64, String ServerIs)
   at OracleInternal.Network.OracleCommunication.Resolve(String tnsAlias, ConnectionOption& CO)
   at OracleInternal.ConnectionPool.PoolManager`3.ResolveTnsAlias(ConnectionString cs, Object OC)
   at OracleInternal.ServiceObjects.OracleConnectionImpl.Connect(ConnectionString cs, Boolean bOpenEndUserSession, OracleConnection connRefForCriteria, String instanceName)
   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)
--- 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()
   at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)
   at Microsoft.EntityFrameworkCore.EntityFrameworkQueryableExtensions.ToListAsync[TSource](IQueryable`1 source, CancellationToken cancellationToken)

Example connectionstrings:
Easy Connect

Data Source=server.industry.net/database;User Id=dataUser;Password=dataPassword

TNS Less

Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=server.industry.net)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=database)));User Id=dataUser;Password=dataPassword;

This is probably a bug in the Oracle.ManagedDataAccess.Client?
Kind regards,
Jochen Jonckheere

This post has been answered by Alex Keh-Oracle on Oct 22 2021
Jump to Answer
Comments
Post Details
Added on Oct 21 2021
13 comments
1,920 views