You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This error is coming every one or other day mostly in night when application is not used.. however I used a ping method to keep connection alive test in each 30 min
setInterval(async()=>{try{awaitkeepConnectionsAlive(dbConnection.dbPool);}catch(err){console.log(`Error during keep-alive process: ${err} at ${newDate()}`);}},1800000);// 30 min interval// Function to keep connections aliveasyncfunctionkeepConnectionsAlive(pool){constpromises=[];constconnectionLimit=pool.pool.config.connectionLimit;consttimeout=500;// Timeout in milliseconds to attempt getting a connectionfor(leti=0;i<connectionLimit;i++){promises.push((async()=>{letconnection;try{connection=awaitPromise.race([pool.getConnection(),newPromise((_,reject)=>setTimeout(()=>reject(newError('Timeout getting connection')),timeout))]);// Validate the connectionconstisValid=awaitpool.validate(connection);if(!isValid){console.log(`Invalid connection ${connection.threadId} detected and destroyed at: ${newDate()}`);awaitconnection.destroy();// Destroy the invalid connection}else{console.log(`Database connection ${connection.threadId} is alive at: ${newDate()}`);}}catch(err){if(err.message==='Timeout getting connection'){console.log(`Skipping connection health check due to timeout at ${newDate()}`);}else{console.log(`Error when checking database health: ${err} at ${newDate()}`);if(connection){awaitconnection.destroy();}}}finally{if(connection){try{awaitconnection.release();}catch(err){console.log(`Error when releasing connection during healthceck health: ${err} at ${newDate()}`);}}}})());}awaitPromise.all(promises).catch(err=>{console.log(`Error during Promise.all: ${err}`);});}
The text was updated successfully, but these errors were encountered:
The error is coming very frequently even if all config is correctly set and ping method is in place.
configuration used as below
This error is coming every one or other day mostly in night when application is not used.. however I used a ping method to keep connection alive test in each 30 min
The text was updated successfully, but these errors were encountered: