title: Node JS Express - Oracle Connection Pooling (ORA-24418: Cannot open further sessions)
body: <p>I'm having issues with a the Oracle DB module:
  <a href="https://github.com/oracle/node-oracledb/blob/master/doc/api.md" rel="nofollow">https://github.com/oracle/node-oracledb/blob/master/doc/api.md</a></p>
  
  <p>I have an application which has between 300 and 900 hits per hour (normally from around 100 users). The application has many $.post requests in the background to retrieve information from a database and display to the user.</p>
  
  <p>I've recently switched to this module as it is Oracle's own (I was using <a href="https://github.com/joeferner/node-oracle" rel="nofollow">https://github.com/joeferner/node-oracle</a> previously).</p>
  
  <p>Here's how I have it set out:</p>
  
  <p><strong>/bin/www</strong></p>
  
  <pre><code>oracledb.createPool(
    {
      user            : 'USER'
      password        : 'PASS',
      connectString   : 'DB:1521/SID:POOLED',
      connectionClass : 'ARBITRARY_NAME',
      poolMin         : 1,
      poolMax         : 50,
      poolTimeout     : 300
    },
    function(err, pool)
    {
  
    if (err) {
        console.log(err);
    }
  
    require('../libs/db')(pool);    // Export pool to separate file
  
   }
  )
  </code></pre>
  
  <p><strong>/libs/db.js</strong></p>
  
  <pre><code>module.exports = function(pool) {
  
  // Require oracle module for formatting
  var oracledb = require('oracledb');
  
  // Export acquire and query function
  module.exports.acquire_and_query = function(sql, params, callback){
  
    // ACQUIRE connection from pool
    pool.getConnection(function(err, connection){
  
      // NUMBER OF CONNCETIONS OPEN
      console.log("ORACLE: CONNX OPEN: " + pool.connectionsOpen);
  
      // NUMBER OF CONNEXTIONS IN USE
      console.log("ORACLE: CONNX IN USE: " + pool.connectionsInUse);
      if (err) {
        console.log(err.message);
        return;
      }
  
      // Use connection to QUERY db and return JSON object
      connection.execute(sql, params, {maxRows: 1000, isAutoCommit: true, outFormat: oracledb.OBJECT}, function(err, result){
  
        // Error Handling
        if (err) {
          console.log(err.message);   // Log the error
          return false;               // Return false for our error handling
        }
  
        // Release the connection back to the pool
        connection.release(function(err) {
          if (err) {
            console.log(err.message);
            return;
          }
        })
  
        // Return callback with rowset first, out bind paramaters second
        return callback(result.rows, result.outBinds, result.rowsAffected);
      })
  
    })
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>This module "acquire_and_query" is called from with in our application, and has SQL and it's params passed in to be executed.</p>
  
  <p>The Oracle DB has a maximum allowed of Pooled connections set to 80 (and we are not exceeding them) - and generally looks pretty happy.</p>
  
  <p>The node application however is constantly throwing out an ORA-24418: Cannot open further sessions, and I am unsure how to resolve this.</p>
  
  <p>Thanks.</p>