You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
I used mysql2 v2.3.3 (use mysql local) and sometimes I got the following error:
Warning: got packets out of order. Expected 6 but received 0 node:events:491 Emitted 'error' event on Connection instance at: at Connection.protocolError (...\node_modules\mysql2\lib\connection.js:397:10) at Connection.handlePacket (...\node_modules\mysql2\lib\connection.js:445:14) [... lines matching original stack trace ...] at TCP.onStreamRead (node:internal/stream_base_commons:190:23) { fatal: true, code: 4031 }
in db.config:
`
const mysql = require("mysql2");
const bluebird = require("bluebird");
const dbConf = {
host: "localhost",
user: "root",
password: "123456",
database: "testdb",
Promise: bluebird,
};
class Database {
static async getDBConnection() {
try {
if (!this.db) {
// to test if credentials are correct
await mysql.createConnection(dbConf);
const pool = mysql.createPool(dbConf);
// now get a Promise wrapped instance of that pool
const promisePool = pool.promise();
this.db = promisePool;
}
return this.db;
} catch (err) {
console.log("Error in database connection");
console.log(err.console.error || err);
}
}
}
module.exports = Database;
`
in app.js:
`
const getUser = asyn (room) => {
let conn = await database.getDBConnection();
let [userInRoom] = await conn.query(
'SELECT testdb.accounts.accountName, testdb.accounts.loginId FROM testdb.userinroom
JOIN testdb.accounts
ON testdb.userinroom.accountId = testdb.accounts.id and testdb.userinroom.roomId = ?;',
room
);
}
`
I can't find any method to fix it. How can I resolve this error?
Thank you.
Vu.
The text was updated successfully, but these errors were encountered:
Hi,
I used mysql2 v2.3.3 (use mysql local) and sometimes I got the following error:
Warning: got packets out of order. Expected 6 but received 0 node:events:491 Emitted 'error' event on Connection instance at: at Connection.protocolError (...\node_modules\mysql2\lib\connection.js:397:10) at Connection.handlePacket (...\node_modules\mysql2\lib\connection.js:445:14) [... lines matching original stack trace ...] at TCP.onStreamRead (node:internal/stream_base_commons:190:23) { fatal: true, code: 4031 }
in db.config:
`
`
in app.js:
`
`
I can't find any method to fix it. How can I resolve this error?
Thank you.
Vu.
The text was updated successfully, but these errors were encountered: