Oracle Connection request timed out c#

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
c#
oracle
asked on Stack Overflow Nov 22, 2017 by Carsten • edited Nov 22, 2017 by Carsten

2 Answers

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.

answered on Stack Overflow Nov 22, 2017 by Kim Bay Andersen
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...


User contributions licensed under CC BY-SA 3.0