Ashutosh
Ashutosh

Reputation: 21

OCIServerAttach() hangs forever

I have observed quite some time that the connection attempt to an Oracle server using OCI library hangs forever and I am not able to find a way out to cancel the hung session. Even Ctrl+C doesn't work.

Do we have an option to call OCIServerAttach API in non-blocking mode or is there is an option that can be used to timeout the OCIServerAttach call?

Please note that the OCI version I am using is 11.2.0

Upvotes: 1

Views: 360

Answers (1)

Christopher Jones
Christopher Jones

Reputation: 10681

Oracle Net can be configured to limit the connection establishment time. The available options have been enhanced in various versions. Oracle 11.2 is 10 years old!!

For recent versions (check the manual for your version), you could create a sqlnet.ora file with options like SQLNET.OUTBOUND_CONNECT_TIMEOUT or TCP.CONNECT_TIMEOUT, or use CONNECT_TIMEOUT in a tnsnames.ora file. Search for 'connect_timeout' in that manual for other choices.

If you use 19c client libraries (that, by the way, will connect to Oracle DB 11.2 or later) then you can even use a timeout option in an Easy Connect connection string like "mydbmachine.example.com/orclpdb1?connect_timeout=15"

Upvotes: 0

Related Questions