Errors while trying to connect after long time.
See original GitHub issueHey team,
We are using node-ibm_db driver for connecting to DB2.
If the app is let unused for sometime or hours together. We get the below errors randomly when trying to use it again.
We were using node-ibm_db V1.0.0 initially, and then updated to V2.0.0 still face these issues.
Error 1: May 08 00:40:21.log: { Error: [IBM][CLI Driver] SQL30081N A communication error has been detected. Communication protocol being used: “TCP/IP”. Communication API being used: “SOCKETS”. Location where the error was detected: “169.111.111.41”. Communication function detecting the error: “send”. Protocol specific error code(s): “110”, “", "”. SQLSTATE=08001
Error description: ETIMEDOUT - Connection timeout
Error 2: May 09 11:57:57.log: message: ‘[IBM][CLI Driver] SQL30081N A communication error has been detected. Communication protocol being used: “TCP/IP”. Communication API being used: “SOCKETS”. Location where the error was detected: “10.111.111.11”. Communication function detecting the error: “send”. Protocol specific error code(s): “104”, “*”, “0”. SQLSTATE=08001\n’,
Error description: ECONNRESET - Connection has been reset by partner
Error 3: May 18 14:19:07.log: message: ‘[IBM][CLI Driver] SQL30081N A communication error has been detected. Communication protocol being used: “TCP/IP”. Communication API being used: “SOCKETS”. Location where the error was detected: “10.111.111.11”. Communication function detecting the error: “recv”. Protocol specific error code(s): “**", "”, “0”. SQLSTATE=08001\n’,
Error description: ,,0 indicates the connection was closed by the peer. This could be any network device (i.e. firewall, router, workload balancing device, etc…) between the client and DB2 server, or the DB2 server itself.
Error 4: May 18 03:06:27.log: { Error: [IBM][CLI Driver] SQL30081N A communication error has been detected. Communication protocol being used: “TCP/IP”. Communication API being used: “SOCKETS”. Location where the error was detected: “169.111.111.41”. Communication function detecting the error: “send”. Protocol specific error code(s): “32”, “*”, “0”. SQLSTATE=08001
Error description: EPIPE (Broken Pipe)
Below is the code on how we create connection.
`
var ibmdb = require(‘ibm_db’);
var pool = new ibmdb.Pool();
var connString = ‘DRIVER={DB2};’ +
‘DATABASE=’+dbName+‘;’+
‘HOSTNAME=’+hostName+‘;’+
‘UID=’+userName+‘;’+
‘PWD=’+password+‘;’+
‘PORT=’+port+‘;’+
‘CURRENTSCHEMA=’+schema+‘;’
‘PROTOCOL=TCPIP’;
module.exports = {
openConnection : function(callback){
pool.open(connString, function (err , connection) {
// Log Error
if (err){
return console.log(err);
} else{
callback(connection);
}
});
}
};`
Can you please help us solve this issue?
Issue Analytics
- State:
- Created 6 years ago
- Comments:11 (5 by maintainers)
Ok, so in an effort to assist others with such issues:
Our path of success (with Bimal’s help):
Configure alternate server on your DB (even if the alternate server is the same one as the original if you don’t have a cluster):
db2 update alternate server for database OUR_DB using hostname OUR_HOSTNAME port OUR_PORT
Configure your db2dsdriver.cfg to recover from failures and have better connection handling parameters. Ours look like this:
Where ALIAS_NAME is the name you want to give to your datasource, DBNAME is the database name over DB2, DB_HOSTNAME is the hostname of your DB2 server, DB_PORT is the port that your DB2 server listens on, DB_USERNAME is the user you use to connect to the DB, DB_PASSWORD the password used by DB_USERNAME to connect and DB_SCHEMA is the actual schema where your DB artifacts are created into.
We are now recovering automatically from failures, retrying one every second for 1 hour (3600 attempts each second) in the event things go wrong, having a keepalive of 5 seconds, aggressive timeouts of 2 secs to wait for a connection to be established with DB.
Hope this helps others and thanks Bimal for the guidance into this. This can be closed.
Thanks @fnschroeder for well documenting the steps to help others. Closing the issue now.