diff --git a/ef-api/controllers/mysqlproperty.js b/ef-api/controllers/mysqlproperty.js index ccdeabc..b729940 100644 --- a/ef-api/controllers/mysqlproperty.js +++ b/ef-api/controllers/mysqlproperty.js @@ -7,9 +7,15 @@ const db = mysql.createConnection({ password: "AVNS_tCXJPnroBpPOhL_c7bR", database: "defaultdb", port: "25060", + waitForConnections: true, connectTimeout: 20000, // 20 seconds + ssl: { + rejectUnauthorized: false, // Required for DigitalOcean managed databases + }, }); + + // const db = mysql.createConnection({ // host: "localhost", // user: "root", diff --git a/ef-api/db/db.js b/ef-api/db/db.js index 5cd8b33..1191e1e 100644 --- a/ef-api/db/db.js +++ b/ef-api/db/db.js @@ -10,7 +10,10 @@ const pool = mysql.createPool({ waitForConnections: true, connectionLimit: 10, // Number of connections in the pool queueLimit: 0, // No limit on queued connection requests - connectTimeout: 20000 // 20 seconds + connectTimeout: 20000, // 20 seconds + ssl: { + rejectUnauthorized: false, // Required for DigitalOcean managed databases + }, }); // Test the pool connection @@ -20,7 +23,7 @@ pool.getConnection() conn.release(); // Release the connection back to the pool }) .catch(err => { - console.error("Database connection failed: " + err.stack); + console.error("MYSQL Database connection failed: " + err.stack); }); export default pool;