Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Exception thrown from thin mode connection finalizer #1748

Answered by sudarshan12s
gcowan-ot asked this question in Q&A
Discussion options

I'm seeing an issue with version 6.8+ when a thin mode connection attempt fails. When the subsequent finalizer runs, an exception is thrown. My service implementation will try connecting with thick mode when the connection fails. The thick mode connection is successful but the service is left in an potentially unstable state due to the thin mode connection finalizer exception. Has anyone else seen this?

finalizer from connection.js
const finalizationRegistry = new global.FinalizationRegistry((heldValue) => {
heldValue.disconnect();
});

exception that is thrown...

C:\iv\oracle-connect\node_modules\oracledb\lib\thin\sqlnet\networkSession.js:640
if (type != constants.NSFIMM && !this.ntAdapter.err) {
^

TypeError: Cannot read properties of null (reading 'err')
at NetworkSession.disconnect (C:\iv\oracle-connect\node_modules\oracledb\lib\thin\sqlnet\networkSession.js:640:53)
at C:\iv\oracle-connect\node_modules\oracledb\lib\thin\connection.js:47:13
at FinalizationRegistry.cleanupSome ()

reason for connection failure

Error: NJS-533: Advanced Networking Option service negotiation failed. Native Network Encryption and DataIntegrity only supported in node-oracledb thick mode.
Cause: ORA-12660
Help: https://docs.oracle.com/error-help/db/ora-12660
at Object.throwErrWithORAError (C:\iv\oracle-connect\node_modules\oracledb\lib\errors.js:746:17)
at ANO.processPacket (C:\iv\oracle-connect\node_modules\oracledb\lib\thin\sqlnet\ANO.js:419:16)
at NetworkSession.connect2 (C:\iv\oracle-connect\node_modules\oracledb\lib\thin\sqlnet\networkSession.js:316:17)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async NetworkSession.connect1 (C:\iv\oracle-connect\node_modules\oracledb\lib\thin\sqlnet\networkSession.js:336:23)
at async NetworkSession.connect (C:\iv\oracle-connect\node_modules\oracledb\lib\thin\sqlnet\networkSession.js:617:5)
at async ThinConnectionImpl.connect (C:\iv\oracle-connect\node_modules\oracledb\lib\thin\connection.js:778:5)
at async Object.getConnection (C:\iv\oracle-connect\node_modules\oracledb\lib\oracledb.js:771:3)
at async Object.getConnection (C:\iv\oracle-connect\node_modules\oracledb\lib\util.js:271:16)
at async tryOracleConnect (C:\iv\oracle-connect\src\oc.js:12:18) {
code: 'NJS-533'
}

You must be logged in to vote

@gcowan-ot Thanks for analysis, I think the state this.connected = true; is incorrectly marked as true without completing ANO (Advanced Networking Options)

const buf = NAContext.sendPacket();

We need to adjust this state to correctly indicate Accept/ANO failures..

diff --git a/lib/thin/sqlnet/networkSession.js b/lib/thin/sqlnet/networkSession.js
index 57f5fe1de..87270f66b 100644
--- a/lib/thin/sqlnet/networkSession.js
+++ b/lib/thin/sqlnet/networkSession.js
@@ -298,7 +298,6 @@ class NetworkSession {
 
 /* Accepted */
 
- this.connected = true;
 this.cData = null;
 this.sndDatapkt = new Packet.DataPacket(this.sAtts.largeSDU);
 this.markerPkt = new Packet.MarkerPacket(th...

Replies: 3 comments 1 reply

Comment options

Some additional info. The issue does not reproduce in version 6.7.0. The connection failure error in 6.7.0 is ...

NJS-521: connection to host 10.96.156.16 port 1521 received end-of-file on communication channel. (CONNECTION_ID=HZz1bdALU4Mei+lWakiOmA==)
at NTTCP.checkErr (C:\iv\oracle-connect\node_modules\oracledb\lib\thin\sqlnet\ntTcp.js:327:29)
at NTTCP.receive (C:\iv\oracle-connect\node_modules\oracledb\lib\thin\sqlnet\ntTcp.js:463:12)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async NetworkSession._recvPacket (C:\iv\oracle-connect\node_modules\oracledb\lib\thin\sqlnet\networkSession.js:391:22)
at async NetworkSession.recvPacket (C:\iv\oracle-connect\node_modules\oracledb\lib\thin\sqlnet\networkSession.js:456:12)
at async ReadPacket.waitForPackets (C:\iv\oracle-connect\node_modules\oracledb\lib\thin\protocol\packet.js:303:18)
at async Protocol._decodeMessage (C:\iv\oracle-connect\node_modules\oracledb\lib\thin\protocol\protocol.js:71:5)
at async Protocol._processMessage (C:\iv\oracle-connect\node_modules\oracledb\lib\thin\protocol\protocol.js:165:9)
at async ThinConnectionImpl.connect (C:\iv\oracle-connect\node_modules\oracledb\lib\thin\connection.js:825:9)
at async Object.getConnection (C:\iv\oracle-connect\node_modules\oracledb\lib\oracledb.js:724:3) {
code: 'NJS-500'
}

The difference in behavior between 6.7.0 and 6.8.0 that results in the exception is that in 6.7.0 when the finalizer calls networkSession.disconnect the this.connected conditional is false. In 6.8.0 the this.connected conditional is true. In both cases type and this.ntAdapter are undefined/null.

disconnect(type) {
if (!this.connected) { // true in 6.8.0 false in 6.7.0
return;
}
if (type != constants.NSFIMM && !this.ntAdapter.err) { // exception is thrown here in 6.8.0
/* Send EOF packet */
this.sndDatapkt.dataLen = this.sndDatapkt.offset;
this.sndDatapkt.prepare2Send(constants.NSPDAFEOF);
this.sendPacket(this.sndDatapkt.dataBuf);
}

You must be logged in to vote
0 replies
Comment options

Hi
Can you please let us know your Oracle Database version and if you are using NNE?
Note that NNE is not enabled in Thin mode.

You must be logged in to vote
0 replies
Comment options

@gcowan-ot Thanks for analysis, I think the state this.connected = true; is incorrectly marked as true without completing ANO (Advanced Networking Options)

const buf = NAContext.sendPacket();

We need to adjust this state to correctly indicate Accept/ANO failures..

diff --git a/lib/thin/sqlnet/networkSession.js b/lib/thin/sqlnet/networkSession.js
index 57f5fe1de..87270f66b 100644
--- a/lib/thin/sqlnet/networkSession.js
+++ b/lib/thin/sqlnet/networkSession.js
@@ -298,7 +298,6 @@ class NetworkSession {
 
 /* Accepted */
 
- this.connected = true;
 this.cData = null;
 this.sndDatapkt = new Packet.DataPacket(this.sAtts.largeSDU);
 this.markerPkt = new Packet.MarkerPacket(this.sAtts.largeSDU);
@@ -319,6 +318,7 @@ class NetworkSession {
 this.sndDatapkt.createPacket(constants.NSPDADAT); //Currently only used for disconnect
 this.sndDatapkt.offset = this.sndDatapkt.dataPtr;
 this.sndDatapkt.len = this.sndDatapkt.bufLen;
+ this.connected = true;
 return (true);
 }

We will valuate the proper fix and would address this issue.

With 6.8.0, You would get this error NJS-533 when the DB has NNE enabled where earlier the error was not informative.. Since finalizer triggered in middle, it caused above issue..

You must be logged in to vote
1 reply
Comment options

@sudarshan12s Thanks, I'll keep an eye out for a fixed version of the library.

Answer selected by gcowan-ot
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /