developers

    Forum Stats

  • 3,874,042 Users
  • 2,266,667 Discussions
  • 7,911,702 Comments

Discussions

Wallet-less connection to ADB from Node API failure

Eric Chao
Eric Chao Member Posts: 1 Green Ribbon

Hi all,

I am building a RESTful API with Node.js and Oracle Autonomous Database, but I am having a couple of issues.

I've deployed the basic server side application to a Heroku endpoint that uses a buildpack to install Oracle Instant Client 19.14, the update from 19.13 which is the version used for wallet-less connections according to the docs. (I am not able to download a wallet since the heroku app is managed for me).


However, the application crashes, for either of two reasons.

  1. First, it seems the createPool method takes too long before the server starts listening and so my heroku deployment times out and crashes. Is there any known reasons why createPool would take so long?
  2. Second problem appears after the workaround of 1 (I initialize the server before the call to createPool). I can see in the log that after a minute or two the server crashes with this error: [Error: ORA-28759: failure to open file] { errorNum: 28759, offset: 0 }

I tried investigating on my own and I read it had something to do with not being able to find the wallet, but I followed the steps outlined in this oracle blog post to enable Wallet less connections. Does anyone have an idea if the error is wallet-related? Could it be something else?

I appreciate any help, I am quite new to the Oracle Cloud Infrastructure and API development in general.

Here is a screenshot from the logs in Problem 2.

Here is the code to my index.js file with the connection and server initialization:

_________________________________

require('dotenv').config();

const webServer = require('./services/web-server');

const database = require('./services/db');

const dbConfig = require('./config/db');

const firebase = require('./services/firebase-admin');

const defaultThreadPoolSize = 4;


// Increase thread pool by poolMax so we can allocate our db pool

process.env.UV_THREADPOOL_SIZE = dbConfig.vtPool.poolMax + defaultThreadPoolSize;


async function startServer() {

  console.log('Starting server:');

  try {

    console.log('Initializing Firebase Admin SDK...');

    firebase.initialize(); 

  } catch (err) {

    console.error(err);

    process.exit(1);

  }


  try {

    console.log('Initializing web server module...');

    await webServer.initialize();

  } catch (e) {

    console.error(e);


    process.exit(1);

  }


  try {

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

    await database.initialize();

  } catch (err) {

    console.error(err);

    // Cannot start our app without db access

    process.exit(1);

  }

}

startServer();



async function shutdown(e) {

  let err = e;

  console.log('Shutting down...');


  try {

    console.log("Attempting to close web server module");


    await webServer.close();

  } catch (e) {

    console.log('Error on shutdown', e);


    err = err || e;

  }


  // Database should close after the web server but before process exits.

  try {

    console.log('Closing database connection');


    await database.close();

  } catch (err) {

    console.log('Error while closing database connection', e);


    err = err || e;

  }


  console.log('Exiting process');


  if (err) {

    process.exit(1);

  } else {

    process.exit(0);

  }

}


/* Controlled shutdown events */

process.on('SIGTERM', () => {

  console.log('Received SIGTERM');


  shutdown();

})


process.on('SIGINT', () => {

  console.log('Received SIGINT');


  shutdown();

})


process.on('uncaughtException', err => {

  console.log('Uncaught exception');

  console.error(err);


  shutdown(err);

})

developers