node-oracledb icon indicating copy to clipboard operation
node-oracledb copied to clipboard

On OCI ADB-23ai with >=oracle-node-6.5.* connection gets NJS-521: connection to host x.x.x.x port 1522 received end-of-file on communication channel.

Open ChaosEngine opened this issue 1 year ago • 7 comments

Driver mode: thin

  1. What versions are you using? >=oracledb-6.5.0 - problem exists with establishing connection <=oracledb-6.4.0 - connection is established
  process.platform: win32 and linux
  process.version: v20.18.0
  process.arch: x64
  require('oracledb').versionString: 6.6.0
  require('oracledb').oracleClientVersionString: undefined
  1. Is it an error or a hang or a crash? Error when trying to establish connection to Oracle OPCI ADB 23ai with mTLS wallet connection.

  2. What error(s) or behavior you are seeing?

Error on Linux:

Error: NJS-500: connection to the Oracle Database was broken
NJS-521: connection to host 138.1.3.227 port 1522 received end-of-file on communication channel. (CONNECTION_ID=oZD/yfgrKj5yUjTpiIh3KA==)
    at NTTCP.checkErr (/home/node/node_modules/.pnpm/[email protected]/node_modules/oracledb/lib/thin/sqlnet/ntTcp.js:327:29)
    at NTTCP.receive (/home/node/node_modules/.pnpm/[email protected]/node_modules/oracledb/lib/thin/sqlnet/ntTcp.js:463:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async NetworkSession._recvPacket (/home/node/node_modules/.pnpm/[email protected]/node_modules/oracledb/lib/thin/sqlnet/networkSession.js:390:22)
    at async NetworkSession.recvPacket (/home/node/node_modules/.pnpm/[email protected]/node_modules/oracledb/lib/thin/sqlnet/networkSession.js:455:12)
    at async ReadPacket.waitForPackets (/home/node/node_modules/.pnpm/[email protected]/node_modules/oracledb/lib/thin/protocol/packet.js:324:18)
    at async Protocol._decodeMessage (/home/node/node_modules/.pnpm/[email protected]/node_modules/oracledb/lib/thin/protocol/protocol.js:70:5)
    at async Protocol._processMessage (/home/node/node_modules/.pnpm/[email protected]/node_modules/oracledb/lib/thin/protocol/protocol.js:153:9)
    at async ThinConnectionImpl.connect (/home/node/node_modules/.pnpm/[email protected]/node_modules/oracledb/lib/thin/connection.js:696:9)
    at async ThinPoolImpl.bgThreadFunc (/home/node/node_modules/.pnpm/[email protected]/node_modules/oracledb/lib/thin/pool.js:437:11) {
  code: 'NJS-500'
}

Error on Windows:

Error: NJS-500: connection to the Oracle Database was broken
NJS-521: connection to host 138.1.3.227 port 1522 received end-of-file on communication channel. (CONNECTION_ID=zvjqbkKtow3Zi2v0rcaOSw==)
    at NTTCP.checkErr (C:\Users\Andrzej\source\repos\ChaosEngine\serverless-scaleway-apollo-typescript\node_modules\.pnpm\[email protected]\node_modules
\oracledb\lib\thin\sqlnet\ntTcp.js:327:29)
    at NTTCP.receive (C:\Users\Andrzej\source\repos\ChaosEngine\serverless-scaleway-apollo-typescript\node_modules\.pnpm\[email protected]\node_modules\
oracledb\lib\thin\sqlnet\ntTcp.js:463:12)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async NetworkSession._recvPacket (C:\Users\Andrzej\source\repos\ChaosEngine\serverless-scaleway-apollo-typescript\node_modules\.pnpm\oracledb@
6.5.0\node_modules\oracledb\lib\thin\sqlnet\networkSession.js:390:22)
    at async NetworkSession.recvPacket (C:\Users\Andrzej\source\repos\ChaosEngine\serverless-scaleway-apollo-typescript\node_modules\.pnpm\oracledb@6
.5.0\node_modules\oracledb\lib\thin\sqlnet\networkSession.js:455:12)
    at async ReadPacket.waitForPackets (C:\Users\Andrzej\source\repos\ChaosEngine\serverless-scaleway-apollo-typescript\node_modules\.pnpm\oracledb@6
.5.0\node_modules\oracledb\lib\thin\protocol\packet.js:324:18)
    at async Protocol._decodeMessage (C:\Users\Andrzej\source\repos\ChaosEngine\serverless-scaleway-apollo-typescript\node_modules\.pnpm\[email protected]
.0\node_modules\oracledb\lib\thin\protocol\protocol.js:70:5)
    at async Protocol._processMessage (C:\Users\Andrzej\source\repos\ChaosEngine\serverless-scaleway-apollo-typescript\node_modules\.pnpm\oracledb@6.
5.0\node_modules\oracledb\lib\thin\protocol\protocol.js:153:9)
    at async ThinConnectionImpl.connect (C:\Users\Andrzej\source\repos\ChaosEngine\serverless-scaleway-apollo-typescript\node_modules\.pnpm\oracledb@
6.5.0\node_modules\oracledb\lib\thin\connection.js:696:9)
    at async ThinPoolImpl.bgThreadFunc (C:\Users\Andrzej\source\repos\ChaosEngine\serverless-scaleway-apollo-typescript\node_modules\.pnpm\oracledb@6
.5.0\node_modules\oracledb\lib\thin\pool.js:437:11) {
  code: 'NJS-500'
}
  1. Include a runnable Node.js script that shows the problem.

Repro using https://github.com/ChaosEngine/serverless-scaleway-apollo-typescript.git project on oracle branch and ADB with mTLS wallet with some password:

git clone --branch=oracle https://github.com/ChaosEngine/serverless-scaleway-apollo-typescript.git
cd serverless-scaleway-apollo-typescript/
mkdir -p credentials/wallet

#execute content of db.sql on ADB database, user adb_test_user  is created with some password and schema

cat << EOF > credentials/oracle-creds.env
NODE_ORACLEDB_USER=adb_test_user
NODE_ORACLEDB_PASSWORD=adb_Password443^2
NODE_ORACLEDB_CONNECTIONSTRING=dataplayground2_medium
NODE_ORACLEDB_WALLET_PASSWORD=123456WalPAs!s
EOF


#obtain wallet.zip with password (if needed) and unzip it under credentials/wallet/
unzip -d credentials/wallet/ wallet.zip
docker build -t oracledb-test .
docker run -it --rm -p 8081:8081 --env-file credentials/oracle-creds.env oracledb-test

Verification - open browser to http://localhost:8081/ and execute following graphql

	query ExampleQuery {
	  dogs {
		id
		name
	  }
	  owners {
		firstname
		lastname
	  }
	}

This should work returning some results

Now breaking it by updating to newest oracldb-6.6.0 (or >oracldb-6.4.0) version

sed  -i 's/"oracledb": "6.4.0"/"oracledb": "6.6.0"/' package.json

#building and running the same
docker build -t oracledb-test .
docker run -it --rm -p 8081:8081 --env-file credentials/oracle-creds.env oracledb-test

Now it does not work giving Error: NJS-500: connection to the Oracle Database was broken

Solution: As suggested here patching solves the issue with oracledb-6.6.0

ChaosEngine avatar Oct 15 '24 08:10 ChaosEngine

Please test it with node-oracledb Thick mode in node-oracledb versions 6.5 and above and let us know if you are able to make the connection.

sharadraju avatar Oct 15 '24 08:10 sharadraju

@ChaosEngine , Can you please confirm if this patch on node-oracledb 6.6.0 works for you?

diff --git a/lib/thin/connection.js b/lib/thin/connection.js
index 6d9d4f05d..84e2d4f02 100644
--- a/lib/thin/connection.js
+++ b/lib/thin/connection.js
@@ -797,8 +797,11 @@ class ThinConnectionImpl extends ConnectionImpl {
           await this._protocol._processMessage(authMessage);
         }
       } else {
+        const endOfRequestSupport = this.nscon.endOfRequestSupport;
+        this.nscon.endOfRequestSupport = false;
         await this._protocol._processMessage(protocolMessage);
         await this._protocol._processMessage(dataTypeMessage);
+        this.nscon.endOfRequestSupport = endOfRequestSupport;
         await this._protocol._processMessage(authMessage);
       }
       if (!params.token) { // non-token Authentication

sudarshan12s avatar Oct 15 '24 10:10 sudarshan12s

If it does not help, please share console prints after setting the below env:

NODE_ORACLEDB_DEBUG_PACKETS=1

sudarshan12s avatar Oct 15 '24 12:10 sudarshan12s

@ChaosEngine , Can you please confirm if this patch on node-oracledb 6.6.0 works for you?

diff --git a/lib/thin/connection.js b/lib/thin/connection.js
index 6d9d4f05d..84e2d4f02 100644
--- a/lib/thin/connection.js
+++ b/lib/thin/connection.js
@@ -797,8 +797,11 @@ class ThinConnectionImpl extends ConnectionImpl {
           await this._protocol._processMessage(authMessage);
         }
       } else {
+        const endOfRequestSupport = this.nscon.endOfRequestSupport;
+        this.nscon.endOfRequestSupport = false;
         await this._protocol._processMessage(protocolMessage);
         await this._protocol._processMessage(dataTypeMessage);
+        this.nscon.endOfRequestSupport = endOfRequestSupport;
         await this._protocol._processMessage(authMessage);
       }
       if (!params.token) { // non-token Authentication

This patch works both on linux and windows. And with thin driver mode. Thank You. How this will be somehow addressed in next release? Any idea what might be the main culprit?

ChaosEngine avatar Oct 15 '24 18:10 ChaosEngine

Please test it with node-oracledb Thick mode in node-oracledb versions 6.5 and above and let us know if you are able to make the connection.

I'd rather stick thin mode instead unnecessarily bundling instant client inside docker image ;->

ChaosEngine avatar Oct 15 '24 18:10 ChaosEngine

@ChaosEngine , Can you please confirm if this patch on node-oracledb 6.6.0 works for you?

diff --git a/lib/thin/connection.js b/lib/thin/connection.js
index 6d9d4f05d..84e2d4f02 100644
--- a/lib/thin/connection.js
+++ b/lib/thin/connection.js
@@ -797,8 +797,11 @@ class ThinConnectionImpl extends ConnectionImpl {
           await this._protocol._processMessage(authMessage);
         }
       } else {
+        const endOfRequestSupport = this.nscon.endOfRequestSupport;
+        this.nscon.endOfRequestSupport = false;
         await this._protocol._processMessage(protocolMessage);
         await this._protocol._processMessage(dataTypeMessage);
+        this.nscon.endOfRequestSupport = endOfRequestSupport;
         await this._protocol._processMessage(authMessage);
       }
       if (!params.token) { // non-token Authentication

This patch works both on linux and windows. And with thin driver mode. Thank You. How this will be somehow addressed in next release? Any idea what might be the main culprit?

Thanks for checking. Yes the fix is already part of coming release . It was seen with specific setting (disabling fast auth) for few ADBs instances.

sudarshan12s avatar Oct 16 '24 06:10 sudarshan12s

Please test it with node-oracledb Thick mode in node-oracledb versions 6.5 and above and let us know if you are able to make the connection.

I'd rather stick thin mode instead unnecessarily bundling instant client inside docker image ;->

Since the patch has worked, I guess we do not need to test with Thick mode. We generally request users to test with Thick mode to narrow down the source of the issue to any Thin-mode related changes.

sharadraju avatar Oct 16 '24 06:10 sharadraju

This is fixed in 6.7 release

sharadraju avatar Nov 18 '24 13:11 sharadraju

The error still appears in version 6.7.1, it only works for local connections, It only works for me with 5.5.0

Error: NJS-500: The connection to the Oracle database was interrupted
NJS-521: The connection to host x.x.x.x port 1521 received end of file on the communication channel.

lamartinezt-indra avatar Jan 16 '25 17:01 lamartinezt-indra