Node-oracledb: Any way to set up timeout for connection?

Created on 10 Sep 2015  路  13Comments  路  Source: oracle/node-oracledb

i catch "Timeout while sql execute" exception after 3 second delay

question

Most helpful comment

please, do you have any straightforward example using callTimeout?

All 13 comments

@wolfeatyou There's nothing specific in node-oracledb for timing out. There are various Oracle DB controls such as resource management that can be used. If you play around with Node timeouts and node-oracledb's break(), let us know how it goes.

@cjbj - break() can only be used on a connection object, however if you can't connect - you just get stuck in a massive timeout, and the application doesn't reply to SIGTERM.

So what I believe @wolfeatyou (and me) are looking for, it a way to say "try and connect for 5 seconds, then error"

@Stono This question was closed almost 2 years ago. Could you please open a new one? Please include details about whether you're using a connection pool or not.

@Stono it's being tracked in https://github.com/oracle/node-oracledb/issues/671. Very platform dependent.

For future searchers finding this topic, in a previous issue I'd mentioned there are Oracle Net settings that may be useful:

I have on my 'to look at' list the OCI call timeout attributes They map to Oracle Net parameters (note the unit is different) which you could set in a sqlnet.ora file right now without waiting for node-oracledb to have an API to set them.

@cjbj would something like this work, or is it just likely to leave orphan connections?

return Promise.race([
    oracledb.getConnection(attributes).then(conn => {
        console.info('Connected to Oracle');
        return conn;
    }),
    new Promise((resolve, reject) => {
        setTimeout(() => {
            reject('Timed out waiting for Oracle connection');
        }, 5000);
    })
]);

@nalbion This thread was originally related to a SQL execution timeout issue (likely related to Workspace Manager). It then moved on to connection.break() not working, which is being tracked in #671. What you're asking about is queuing on getConnection, right?

There's already a queue on getConnection. Its timeout can be configured via queueTimeout.

queueTimeout does not work!
That's the point.
It always waits 60 seconds!

@nickperkinslondon Do you have a test case that demonstrates that it's not working?

The doc at https://oracle.github.io/node-oracledb/doc/api.html#connectionha now has just a bit more on the topic of preventing the establishment of connections over the wire to the DB from appearing to hang if there is a network issue. E.g. use SQLNET.OUTBOUND_CONNECT_TIMEOUT in a sqlnet.ora file (on the Node.js tier). To prevent the same when executing statements there are other parameters mentioned, or you can now use callTimeout directly in node-oracledb.

hi @cjbj do you know if there is any solution better then a Promise race like @nalbion suggested before? I tried the callTimeout but it does not worked

@rnogueira-namoadigital see my immediately previous answer.

please, do you have any straightforward example using callTimeout?

Was this page helpful?
0 / 5 - 0 ratings