my node.js file is interacting with a MySQL database through the MySQL module. For now I basically just create a pool
var connection = mysql.createPool(dataConnection);
then I make simple queries using connection.query()
.
Sometimes I get an error saying Error: Connection lost: The server closed the connection.
From what I've understood, whenever I call the query method a brand new connection is created from the pool, then it is closed immediately after it is done. Hence I am quite puzzled: how can the connection be closed since the server should explicitly create one for this query? And, most importantly, is there a way I can actually avoid this issue (which doesn't happen too often, fortunately, but still).
Thanks for your help!
Noël.