title: Oracle Connection request timed out c#
body: <p>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</p>
  
  <p>When I try to run the release files on the Batch PC and the Laptop I get the following error.</p>
  
  <pre><code>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
  </code></pre>
  
  <p>The connection string used</p>
  
  <pre><code>&lt;connectionStrings&gt;
  &lt;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"/&gt;
  </code></pre>
  
  <p>
  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.</p>
  
  <p>The following is the code where I make the connection to the database and it returns the data needed. (Line:25 is -> conn.Open() )</p>
  
  <pre><code>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&lt;BatchDeadCheck&gt;();
                  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 = $"&gt; 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;
          }
      }
  </code></pre>
  
  <p>So far I've checked every link on the first page on google, when googling the 
  "<strong><em>c# Connection request timed out</em></strong>"
  And I've done some reading on the oracle connection pooling in <a href="https://docs.oracle.com/cd/E51173_01/win.122/e17732.pdf" rel="nofollow noreferrer">Oracle® Data Provider for .NET</a> without getting any real solutions</p>
  
  <p><strong>Update:</strong>
  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</p>
  
  <pre><code>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
  </code></pre>