1

I am currently working on an application that does a few different things, but I've run into a problem where the application only works on mine and others development computers and not on a non development laptop and a Virtual PC running batch assignments

When I try to run the release files on the Batch PC and the Laptop I get the following error.

Exception took place in:  PR Get(OracleInternal.ConnectionPool.ConnectionString, Boolean, OracleInternal.ConnectionPool.CriteriaCtx, System.String, Boolean)
Data:  System.Collections.ListDictionaryInternal
H Result:  -2147467259
Message:  Connection request timed out
Stack Trace:     at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, CriteriaCtx criteriaCtx, String affinityInstanceName, Boolean bForceMatch)
at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, CriteriaCtx criteriaCtx, String affinityInstanceName, Boolean bForceMatch)
at OracleInternal.ConnectionPool.OracleConnectionDispenser 3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, CriteriaCtx criteriaCtx)
at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
at BatchErrorScreenshotter.Program.DatabaseChecker.GetAllBatchesFromDB() in C:\Users\clm\documents\visual studio 2015\Projects\BatchErrorScreenshotter\BatchErrorScreenshotter\Program\DatabaseChecker.cs:line 25

The connection string used

<connectionStrings>
<add name="OracleConnectionXALP" providerName="Oracle.ManagedDataAccess.Client"
  connectionString="User Id=XXXXX;Password=XXXXX;Data Source=XALP;Min Pool Size=2; Connection Lifetime=30;Connection Timeout=10;Incr Pool Size=1;Decr Pool Size=1"/>

I have tried fiddling with it, changing the different values without much of a change in the results. I tried adding a Max Pool Size of 200, an increase from the default 100. But it did not work.

The following is the code where I make the connection to the database and it returns the data needed. (Line:25 is -> conn.Open() )

public DatabaseCheckWrapper GetAllBatchesFromDB()
    {
        try
        {
            using (var conn = new OracleConnection(ConfigurationManager.ConnectionStrings["OracleConnectionXALP"].ConnectionString))
            {
                conn.Open(); // Line 25, Connection error happens here
                DatabaseCheckWrapper dbw = new DatabaseCheckWrapper();
                OracleCommand cmd = new OracleCommand()
                {
                    CommandText = $"xal_supervisor.batchmonitor_pkg.get_batchmonitor",
                    CommandType = CommandType.StoredProcedure,
                    Connection = conn
                };

                OracleParameter p1 = new OracleParameter
                { OracleDbType = OracleDbType.RefCursor, ParameterName = "batchmonitor_ud", Direction = ParameterDirection.Output };

                cmd.Parameters.AddRange(new[] { p1 });

                var reader = cmd.ExecuteReader();

                var batches = new List<BatchDeadCheck>();
                while (reader.Read())
                {
                    var batch = new BatchDeadCheck();
                    batch.DXDEMINUTTER = reader.GetInt32(0);
                    batch.ACCEPTDXDEMINUTTER = reader.GetInt32(1);
                    // ACTION NAME IS ?Mainwindowtitle?
                    batch.ACTIONNAME = $"{reader.GetString(2)} (tilsluttet)";
                    batch.SESSIONSTATUS = reader.GetString(3);
                    batch.ADVERSELEMAIL = reader.GetString(4);
                    batch.ILIVETID = reader.GetInt32(5);
                    batches.Add(batch);
                }
                dbw.DisplayText = $"> Database batch check was run at {DateTime.Now.ToString("T")}";
                dbw.Batches = batches;
                conn.Close();
                return dbw;
            }
        }
        catch (Exception e)
        {
            DatabaseCheckWrapper dbwError = new DatabaseCheckWrapper();
            dbwError.DisplayText = $"!!Error has occurred while retrieving data from the Database!!";
            dbwError.Batches = null;
            dbwError.Exception = e;
            return dbwError;
        }
    }

So far I've checked every link on the first page on google, when googling the "c# Connection request timed out" And I've done some reading on the oracle connection pooling in Oracle® Data Provider for .NET without getting any real solutions

Update: I decided to try and ping the db server and found that my laptop couldn't reach it, but the batch PC could. So I'll be testing on the Batch PC now. I also got the following error log on my first run on the Batch PC

Data:  System.Collections.ListDictionaryInternal
Inner Exception:  OracleInternal.Network.NetworkException (0x00002F7A): ORA-12154: TNS:could not resolve the connect identifier specified
at OracleInternal.Network.AddressResolution..ctor(String TNSAlias, String instanceName)
at OracleInternal.Network.OracleCommunication.DoConnect(String tnsDescriptor)
at OracleInternal.Network.OracleCommunication.Connect(String tnsDescriptor, Boolean doNAHandshake, String IName)
at OracleInternal.ServiceObjects.OracleConnectionImpl.Connect(ConnectionString cs, Boolean bOpenEndUserSession, CriteriaCtx criteriaCtx, String instanceName)
Message:  ORA-12154: TNS:could not resolve the connect identifier specified
Stack Trace:     at OracleInternal.ConnectionPool.PoolManager`3.Get(ConnectionString csWithDiffOrNewPwd, Boolean bGetForApp, CriteriaCtx criteriaCtx, String affinityInstanceName, Boolean bForceMatch)
at OracleInternal.ConnectionPool.OraclePoolManager.Get(ConnectionString csWithNewPassword, Boolean bGetForApp, CriteriaCtx criteriaCtx, String affinityInstanceName, Boolean bForceMatch)
at OracleInternal.ConnectionPool.OracleConnectionDispenser`3.Get(ConnectionString cs, PM conPM, ConnectionString pmCS, SecureString securedPassword, SecureString securedProxyPassword, CriteriaCtx criteriaCtx)
at Oracle.ManagedDataAccess.Client.OracleConnection.Open()
at BatchErrorScreenshotter.Program.DatabaseChecker.GetAllBatchesFromDB() in C:\Users\clm\documents\visual studio 2015\Projects\BatchErrorScreenshotter\BatchErrorScreenshotter\Program\DatabaseChecker.cs:line 25
Carsten
  • 133
  • 4
  • 12
  • Your laptop and computer can not connect to the database. Can you test the possibility of connecting from them to the database in some other way, for example, from sql IDE (Oracle SQL Developer). Or, maybe, incrace `Connection Timeout=10` (e.g. to 30) – Anton Gorbunov Nov 22 '17 at 10:53
  • The batch PC and Laptop currently do not have any SQL IDE's installed on them, and I have tried raising the connection timeout to 120. Without it helping. – Carsten Nov 22 '17 at 10:58
  • 1
    i don't see server name in .Is it ok - are you using TNS? – Anton Gorbunov Nov 22 '17 at 11:04
  • 1
    May you try setup full server settings in connection string. It looks like this should look like this: `Data Source=server_name:port/db_instance_name; Initial Catalog=data_base_name;` – Anton Gorbunov Nov 22 '17 at 11:12
  • 2
    Or maybe you not setup `tnsnames.ora` file on client? Dedault path is `ORACLE_HOME%\network\admin` Documentation about this here: https://docs.oracle.com/cd/B28359_01/network.111/b28317/tnsnames.htm#NETRF262 – Anton Gorbunov Nov 22 '17 at 11:26
  • @AntonGorbunov, according documentation this is not true for the ODP.NET Managed Driver, see https://docs.oracle.com/cd/E63277_01/win.121/e63268/InstallManagedConfig.htm#ODPNT8161, however check this investigation: https://stackoverflow.com/questions/28280883/determining-location-of-relevant-tnsnames-ora-file/28283924#28283924 – Wernfried Domscheit Nov 22 '17 at 11:38

2 Answers2

3

Have you checked if an tnsnames.ora file is available on the machine where you get error ORA-12154: TNS:could not resolve the connect identifier specified

Check your system enviroment variables for "TNS_ADMIN", if not found then create it with reference to folder where tnsnames.ora should be placed. Then copy tnsnames.ora from your development pc.

Kim Bay Andersen
  • 279
  • 2
  • 12
  • Ah right, yeah that did It. You and Anton both gave me really good help here. I checked and found the tnsnames.ora was missing and added the path to the file and now the application works as it should. – Carsten Nov 22 '17 at 11:41
0

Verified from able to reach the Oracle database host/port from the server where database agent is installed.

You can find more information about network requirements here.

https://docs.appdynamics.com/display/PRO44/Database+Visibility+System+Requirements#DatabaseVisibilit...