Hello when making calls to the mysql server if the connection is not open/disconnected due to a long time of not using it then it will give me an error when I attempt to Re-Connect. I have looked this error up but the responses don't seem to help me in my situation. Here is the error: Cannot enqueue Handshake after already enqueuing a Handshake. Here is the code causing this:
var con = mysql.createConnection({
host: "",
user: "",
password: "",
database: ""
});
con.connect(function(err) {
if (err) throw err;
console.log("Connected!");
});
con.on('error', function(err) {
console.log(err);
console.log('MYSQL Disconnected');
})
if (con.state == 'disconnected') {
con.connect(function(err) {
if (err) throw err;
});
}
More code is below but is irrelevant due to it checking for authenticated state and querying