I have a node program that queries the local database every hour and then queries the intranet database again. only appears read ECONNRESET when querying the intranet database.
use npm library knex + mysql2 to connect to the database, knex is configured as follows (connection pooling is used)
require("knex")({
client: "mysql2",
connection: {
host : "127.0.0.1",
user : "your_database_user",
password : "your_database_password",
database : "myapp_test"
}
pool: {
min: 5,
max: 1000
},
acquireConnectionTimeout: 60000,
asyncStackTraces: false, //
migrations: {
tableName: "knex_migrations" //
},
log: {
warn (message) {
console.log("[knex warn]", message)
},
error (message) {
console.log("[knex error]", message)
},
deprecate (message) {
console.log("[knex deprecate]", message)
},
debug (message) {
console.log("[knex debug]", message)
}
}
})
show variables like "wait_timeout"; of mysql
is
that is, 8 hours.
according to this answer: https://stackoverflow.com/a/2.
should not appear read ECONNRESET , mysql the time to close useless connections is 8 hours , and I query the database every hour, there is a high probability of this problem, not to mention that I also use connection pooling. knex must be a connection pool using mysql2 ? Doesn"t the connection pool of mysql2 automatically maintain these connections?
