I\'m trying to reproduce a MySQL error I\'m seeing in my node.js app on EC2 with the node mysql library:
Connection lost: The server closed the connec
The solution is use pooling connection !
You can wrote code to handle connection manually, it works. However pooling is design for this, use pooling connection solved connection drop error.
var mysql = require('mysql');
var pool = mysql.createPool({
connectionLimit : 10,
host : 'example.org',
user : 'bob',
password : 'secret',
database : 'my_db'
});
pool.query('SELECT 1 + 1 AS solution', function (error, results, fields) {
if (error) throw error;
console.log('The solution is: ', results[0].solution);
});
pooling mysql connection