简体   繁体   中英

Error closing node-oracledb pool connections with Oracle DB and Node.js

I have problems closing the connection to the database in Oracle. First I create the connection without any problems.

  try {
  console.log('Initializing database module');

  await database.initialize();
  } catch (err) {
  console.error(err);

  process.exit(1); // Non-zero failure code
  }


async function initialize() {
  console.log(dbConfig.hrPool);
  const pool = await oracledb.createPool(dbConfig.hrPool);
}

module.exports.initialize = initialize;

when I want to close the connection, the application is waiting without answering anything, so I do it to end the connection

  try {
  console.log('Closing database module');
  console.log(" here 1");
  await database.close();// line  whit problem
  console.log(" here 2");
  } catch (err) {
  console.log('Encountered error', e);

  err = err || e;
  }

async function close() {
  await oracledb.getPool().close();
}

module.exports.close = close;


also note that I use a vpn connection for the database

Review pool.close() documentation :

  1. You probably want to specify a drainTime value otherwise the pool may not actually close.

  2. You may need to add DISABLE_OOB=ON to a sqlnet.ora file

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM