Skip to content

Commit

Permalink
PROTOCOL_PACKETS_OUT_OF_ORDER 해결2
Browse files Browse the repository at this point in the history
  • Loading branch information
SiHoonChris committed May 20, 2023
1 parent d62a331 commit 04e8fc9
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 0 additions & 2 deletions app.js
Expand Up @@ -10,8 +10,6 @@ var numOfViewers = require('./routes/numOfViewers');
var countViewers = require('./routes/countViewers');

var app = express();
const connection = require('./routes/mysql');
connection.connect();

// view engine setup
app.set('views', path.join(__dirname, 'views'));
Expand Down
4 changes: 3 additions & 1 deletion routes/mysql.js
@@ -1,11 +1,13 @@
const mysql = require('mysql');
require('dotenv').config();

const connection = mysql.createPool({
const dbConfig = ({
database: process.env.DB_DATABASE,
host: process.env.DB_HOST,
user: process.env.DB_USER,
password: process.env.DB_PASSWORD
});

const connection = mysql.createPool(dbConfig);

module.exports = connection;

1 comment on commit 04e8fc9

@SiHoonChris
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

2023.05.20 에러 해결 : PROTOCOL_PACKETS_OUT_OF_ORDER

원인

DB wait_timeout : 8시간(default), (8시간 동안 DB에 쿼리 접속 없으면 자동으로 DB 서버 죽음)

해결

.createConnection => .createPool

참고

mysqljs/mysql#2534
https://stackoverflow.com/questions/73957523/expressjs-with-mysql-protocol-packets-out-of-order
https://webaura.tistory.com/entry/NodeJS-Mysql-%EC%97%B0%EA%B2%B0%ED%95%98%EA%B8%B0-Mysql-createPool

Please sign in to comment.