Grazie Alka per essermi vicino.
Sto cercando di proseguire nella ricerca dell'errore. Ho visto, analizzando il log di PM2 vedo che cìè un errore legato alla connessione a mysql. Credo che l'errore
Motivo: l’header “autorization” non è consentito a causa dell’header “Access-Control-Allow-Headers” nella risposta CORS preliminare (“preflight”) sia errore di riflesso.
su log pm2 mi viene evidenziato
/home/ubuntu/.pm2/logs/Sif-error.log last 15 lines:
0|Sif | Warning: got packets out of order. Expected 21 but received 0
0|Sif | 2025-02-20T02:51:34.536Z MySQL error 4031
0|Sif | Ignoring invalid configuration option passed to Connection: idleTimeout. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection
ho cercato su internet il problema segnalato
Warning: got packets out of order. Expected 21 but received 0
0|Sif | 2025-02-20T02:51:34.536Z MySQL error 4031
e vedo che fanno riferimento ai parametri di mysql.createPool
questo è il mio file db.js
// definizioni del database -- nuova versiona dal 24/11/2021 ---- su ambiente sviluppo (bangia_test)
const config = require("./config.json");
const mysql = require('mysql2');
// originale per sviluppo su localhost
const Sequelize = require('sequelize')
const sequelize = new Sequelize(
config.database,
config.user,
config.password,
{
host: config.host,
dialect: config.dialect,
operatorsAliases: 0,
pool: {
max: config.pool.max,
min: config.pool.min,
acquire: config.pool.acquire,
idle: config.pool.idle
}
}
);
let db;
// ambiente di Produzione EC2
if(process.env.CLEARDB_DATABASE_URL) {
db = mysql.createConnection(process.env.CLEARDB_DATABASE_URL)
} else {
db = mysql.createPool({
connectionLimit: 100,
host: config.host,
user: config.user,
password: config.password,
database:config.database,
port:config.port,
waitForConnections: true,
connectionLimit: 10,
queueLimit: 0,
debug: false
});
}
// Attempt to catch disconnects
db.on('connection', function (connection) {
console.log('DB Connection correttamente aperta');
connection.on('error', function (err) {
console.error(new Date(), 'MySQL error', err.code);
});
connection.on('close', function (err) {
console.error(new Date(), 'MySQL close', err);
});
});
viene fatto anche un rilevo legato a idleTimeout ceh nella mia mysql.createPool non viene menzionata
Ignoring invalid configuration option passed to Connection: idleTimeout. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection
Credo che se si riesce a sistemare questo errore, tutto dovrebbe risolversi.
Hai qualche idea su come gestire l'errore
/home/ubuntu/.pm2/logs/Sif-error.log last 15 lines:
0|Sif | Warning: got packets out of order. Expected 21 but received 0
0|Sif | 2025-02-20T02:51:34.536Z MySQL error 4031
0|Sif | Ignoring invalid configuration option passed to Connection: idleTimeout. This is currently a warning, but in future versions of MySQL2, an error will be thrown if you pass an invalid configuration option to a Connection
la mysql.createPool è correttamente impostata ?
Grazie
Moreno