Sequelize.js: how to handle reconnection with MySQL
Solution 1
There is an open issue for this in Sequelize:
https://github.com/sequelize/sequelize/issues/2113
Based on that, this error is handled in sequelize.
Solution 2
I verified the version 4.11.1 of sequelize has this issue fixed.
The queries will fail when the database server is down, but will recover to reconnect and succeed when the database server is up.
(You don't need to restart the application as faced with previous versions.)
Luciano
Updated on June 12, 2022Comments
-
Luciano almost 2 years
I've always used Mongo with Node, but now due to an existing datasource I need to connect a node app with Mysql.
Sequelize seems a good solution, but I don't get how to handle connection error, reconnection and re-tries.
To check for connection error on first run
.authenticate().then().catch(function(error){...});
But what if I loose connection and want to reconnect?