JavaScript to Oralce OCI error NJS-511: connection to listener at host x.x.x.x port xxxx was refused. Cause: ORA-12506

288 Views Asked by At

I'm busy making a JavaScript App to connect to Oracle OCI with a wallet but with no success yet. It looks like all the needed Node.js files are installed.

The error msg is:

Error: NJS-511: connection to listener at host x.x.x.x port xxxx was refused. (CONNECTION_ID=xxxx)
Cause: ORA-12506
    at Object.throwErr ()
    at NetworkSession.connect2 ()
    at process.processTicksAndRejections ()
    at async NetworkSession.connect1 ()
    at async NetworkSession.connect ()
    at async ThinConnectionImpl.connect ()
    at async Object.getConnection ()
    at async runTest () {code: 'NJS-511', stack: 'Error: NJS-511: connection to listener at  )', message: 'NJS-511: connection to listener at host )
Cause: ORA-12506'}

It is using TNSNAMES.ORA correctly because the IP and PORT that is shown in the error message is the same as in the physical file.

The App looks like this:

const oracledb = require('oracledb');
const config = {
  user: ‘xxxx’
  ,password: ‘xxxx’
  ,connectString: ‘xxxx’
}; 

async function runTest() {
  let conn; 

  try {
    conn = await oracledb.getConnection(config);
    let result = await conn.execute(
      'select hello world from dual'
    );
    console.log(result);
  } catch (err) {
    console.error(err);
  } finally {
    if (conn) {
      try {
        await conn.close();
      } catch (err) {
        console.error(err);
      }
    }
  }
} 
runTest();

According to Oracle this error means there is filtering happening and that my pc IP needs to be on some form of a 'White List':

    DatabaseError: ORA-12506: TNS:listener rejected connection based on service ACL filtering

But I'm able to connect via SQL Developer using the wallet without any form of 'Adding my IP to a list or an exception on a firewall'.

Can connect via SQL Developer

It's not clear why JavaScript rejects the connection but SQLDeveloper connects to it without issues. I probably need to point the app to other files in the wallet for proper handshaking.

Has anyone had similar issues or has an idea what is causing this?

1

There are 1 best solutions below

0
Jyoti Saini On

Can you try using OCI SDK for typescript and JavaScript to connect to oracledb? https://www.npmjs.com/package/oci-sdk