You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am trying to follow the instructions here and the sample here to use .NET Core to connect to an Autonomous Database in Oracle cloud.
However, the connection attempt fails with:
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 UserQuery.Main() in C:\Users\mikea_000\AppData\Local\Temp\LINQPad6\_khszaeot\wvhmgd\LINQPadQuery:line 30
Here is the C# code I'm using to connect:
//Demo: ODP.NET Core application that connects to Oracle Autonomous DB//Enter user id and password, such as ADMIN user stringconString="User Id=ADMIN;Password=MyAdminPassword;"+//Enter net service name for data source value"Data Source=dltest_high;";OracleConfiguration.TraceFileLocation=@"C:\Users\mikea_000\Downloads";OracleConfiguration.TraceLevel=7;using(OracleConnectioncon=newOracleConnection(conString)){using(OracleCommandcmd=con.CreateCommand()){try{//Enter directory where the tnsnames.ora and sqlnet.ora files are locatedOracleConfiguration.TnsAdmin=@"C:\Users\mikea_000\Downloads\Wallet_DLTest";//Alternatively, connect descriptor and net service name entries can be placed in app itself//To use, uncomment below and enter the DB machine port, hostname/IP, service name, and distinguished name//Lastly, set the Data Source value to "autonomous"//OracleConfiguration.OracleDataSources.Add("autonomous", "(description=(address=(protocol=tcps)(port=<PORT>)(host=<HOSTNAME/IP>))(connect_data=(service_name=<SERVICE NAME>))(security=(ssl_server_cert_dn=<DISTINGUISHED NAME>)))"); //Enter directory where wallet is stored locallyOracleConfiguration.WalletLocation=@"C:\Users\mikea_000\Downloads\Wallet_DLTest";con.Open();Console.WriteLine("Successfully connected to Oracle Autonomous Database");//Retrieve database version infocmd.CommandText="SELECT BANNER FROM V$VERSION";OracleDataReaderreader=cmd.ExecuteReader();reader.Read();Console.WriteLine("Connected to "+reader.GetString(0));}catch(Exceptionex){Console.WriteLine(ex.ToString());}}}
It looks like you encountered an ORA-12506 TNS: listener rejected connection based on service ACL filtering.
The most common reason is if you have an ACL setup for your ADB such that it only allows access to certain IPs, CIDR blocks, VCN, etc. Enable your specific IP or you can disable ACL. You will see this setting on the ADB configuration page, such as what you see here:
If you work at home, whatismyip will give your actual IP address.
.
Worked like a charm. Thanks @alexkeh ! If this is determinable from the trace, it would be great to surface it in the exception message rather than just saying "request timed out". Do you agree?
The timeout is the first error that was hit. It should be the exception returned. The ORA-12506 was the second error. If the timeout was increased to two minutes long, then you should see the ORA-12506 as the first exception.
The ODP.NET default connection timeout, 15 seconds, is fairly low for the purposes of troubleshooting connectivity issues. The default is designed for a typical runtime experience in which an app wouldn't want a user to have to wait too long before returning a result.
I am trying to follow the instructions here and the sample here to use .NET Core to connect to an Autonomous Database in Oracle cloud.
However, the connection attempt fails with:
Here is the C# code I'm using to connect:
I've attached the trace file as well
LINQPAD6.QUERY.EXE_PID_11196_DATE_2021_12_11_TIME_11_09_24_882805.trc.zip
.
The text was updated successfully, but these errors were encountered: