diff --git a/dbhandler.js b/dbhandler.js index e8df910..2aab11f 100644 --- a/dbhandler.js +++ b/dbhandler.js @@ -11,20 +11,8 @@ if (serverType === 1) { function establishConnection() { return new Promise((resolve, reject) => { pool.getConnection(function(err, con) { - if (err) throw err; // not connected! + if (err) console.error("ERR: You lost a connection.\n" + err ); // not connected! resolve(con); - con.on('error', function(err) { - console.log('MySQL error', err); - if (err.code === 'PROTOCOL_CONNECTION_LOST') { - console.log('Reconnecting MySQL connection...'); - con = mysql.createConnection(connection.config); - pool.getConnection(function(err, connection) { - if (err) throw err; // not connected! - }); - } else { - throw err; - } - }); }); }); } @@ -52,8 +40,8 @@ async function getUserCount() { reject(err) throw err }; - resolve(JSON.parse(JSON.stringify(result)).length); con.release(); + resolve(JSON.parse(JSON.stringify(result)).length); }); }); } @@ -106,8 +94,8 @@ async function getUserData(req) { } if (mUser) { // Return a Response with the whole identifiable user data. the EXT_ID will be used later to identify images and other things and match them to the user's profile. - resolve(mUser); con.release(); + resolve(mUser); } else { reject(new Error('User not found')); } @@ -160,8 +148,8 @@ async function getExtId(req) { } if (mUser) { // Return a Response with the whole identifiable user data. the EXT_ID will be used later to identify images and other things and match them to the user's profile. - resolve(mUser); con.release(); + resolve(mUser); } else { reject(new Error('User not found')); } @@ -214,8 +202,8 @@ async function getUserScores(req) { } } // Return a Response with all the Scores listed under that user. - resolve(mUser) con.release(); + resolve(mUser); }) }); } @@ -266,8 +254,8 @@ async function getUserArea(req) { } } // Return a Response with all the Scores listed under that user. - resolve(mUser) con.release(); + resolve(mUser) }) }); }