MySQL2 Etimedout-Fehler mit rate-limiter-flexibelMySql

MySQL DBMS-Forum
Anonymous
 MySQL2 Etimedout-Fehler mit rate-limiter-flexibel

Post by Anonymous »

Ich arbeite an einem Backend -Projekt von Node.js und habe ein seltsames Problem mit MySQL -Verbindungen. Hier ist die Situation: < /p>

Ich verwende eine MySQL -Datenbank, die auf digitalem Ozean gehostet wird (verwaltete MySQL -Cluster). Rate-limiter-flexible Bibliothek für Anfrage drosseln.import { Sequelize } from "sequelize";
import { production } from "./config.js";

const sequelize = new Sequelize(
production.DB,
production.USERNAME,
production.PASSWORD,
{
host: production.HOST,
port: production.PORT,
dialect: "mysql",
dialectOptions: {
charset: "utf8",
},
timezone: "+03:00",
}
);

sequelize.authenticate()
.then(() => console.log("Connection has been established successfully."))
.catch((err) => console.error("Unable to connect to the database:", err));
< /code>
Dies stellt jedes Mal erfolgreich eine Verbindung her.import { RateLimiterMySQL } from "rate-limiter-flexible";
import mysql from "mysql2";
import { production } from "../config/config.js";

const mysqlConfig = {
host: production.HOST,
user: production.USERNAME,
password: production.PASSWORD,
database: production.DB,
port: production.PORT,
// connectTimeout: 10000 // even tried increasing this
};

const setup = async () => {
const pool = mysql.createPool(mysqlConfig);

const createBlockTableSQL = `
CREATE TABLE IF NOT EXISTS rate_limit_block (
ip_address varchar(100) NOT NULL,
points int(11) unsigned NOT NULL DEFAULT '0',
expire BIGINT,
PRIMARY KEY (ip_address)
)
`;

return new Promise((resolve, reject) => {
pool.query(createBlockTableSQL, (err) => {
if (err) return reject(err);

try {
const blockLimiter = new RateLimiterMySQL({
storeClient: pool,
tableName: "block",
tablePrefix: "rate_limit_",
points: 20,
duration: 60,
blockDuration: 60 * 60 * 24,
storeType: "mysql",
});

resolve({ blockLimiter });
} catch (error) {
reject(error);
}
});
});
};
< /code>
Ich erhalte den folgenden Fehler: < /p>
Error: connect ETIMEDOUT
at PoolConnection._handleTimeoutError (node_modules/mysql2/lib/connection.js:205:17)
at listOnTimeout (node:internal/timers:581:17)
at process.processTimers (node:internal/timers:519:7)
< /code>
Zusätzlicher Kontext
Die Host, Port, Benutzer, Kennwort und Datenbank sind zwischen den Konfigurationen der Folgen- und MySQL2 -Konfigurationen identisch. Metriken). < /p>
Die gleichen Anmeldeinformationen funktionieren in MySQL Workbench und Folge ohne Probleme. MySQL2 (über rate-limiter-flexible) massive aus? /> < /li>
Was kann ich tun, um dies weiter zu debuggen und festzustellen, ob sich das Problem auf der digitalen Ozeanseite befindet oder wie ich den Pool initiiere? Ich bin stundenlang daran festgehalten und würde gerne von jedem hören, der mit einer verwalteten MySQL-Datenbank wie Digital Ocean von Digital Ocean eine verwaltete MySQL-Datenbank verwendet hat.>

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post