ibmdb / node-ibm_db

IBM DB2 and IBM Informix bindings for node
MIT License
188 stars 151 forks source link

How to set timeout when using connection pool? #954

Closed girish-jha closed 8 months ago

girish-jha commented 8 months ago

Hi, We need to set a timeout for our ibm_db connections. We are using pools for connection and we have found it quite performant. But if the connection takes more than a certain amount of time due to some issues we want it to error out rather than waiting for a long period of time. We found a method on the pool but the body of it is commented

image

Could you please suggest if there is any other method to set the timeout while using connection pools?

bimalkjha commented 8 months ago

@girish-jha Better to increase the maxPoolSize so that new connection can get created and added to the pool. Its value can be upto 255. Since, all connections of the pool are busy and there is no connection to return for open request, connection keeps waiting to get returned to the pool. So, increasing maxPoolSize could help if you are setting it in the app.

If you have not set maxPoolSize, then it can grow automatically. In this case, you can set the timeout value at start as pool = new ibmdb.Pool({connectTimeout : 60}); to set the connection timeout as 60 seconds. Thanks.

bimalkjha commented 8 months ago

Closing the issue as solution already shared. Thanks.