1
0
mirror of https://dev.s-ul.net/Galexion/MaiMaiDXNet.git synced 2024-11-12 04:00:47 +01:00

HotFix: Fixing ECONNRESET for Artemis users.

This commit is contained in:
Galexion 2023-07-19 13:13:39 -04:00
parent 6e63285a82
commit 769317c0d7
3 changed files with 17 additions and 12 deletions

View File

@ -5,17 +5,13 @@ if (serverType === 0) {
db = new sqlite3.Database(aquaSrvDir + '\\db.sqlite');
}
const mysql = require('mysql');
var con = mysql.createConnection(ArtConnSettings)
//var con = mysql.createConnection(ArtConnSettings);
var pool = mysql.createPool(ArtConnSettings);
var con = undefined
if (serverType === 1) {
con.connect((err) => {
if (err) {
console.error('Error connecting to MySQL database:', err);
process.exit()
return;
}
console.log('Connected to MySQL database.');
pool.getConnection(function(err, connection) {
if (err) throw err; // not connected!
con = connection;
});
}
@ -41,6 +37,7 @@ async function getUserCount() {
throw err
};
resolve(JSON.parse(JSON.stringify(result)).length);
con.release();
});
});
}
@ -94,6 +91,7 @@ async function getUserData(req) {
if (mUser) {
// Return a Response with the whole identifiable user data. the EXT_ID will be used later to identify images and other things and match them to the user's profile.
resolve(mUser);
con.release();
} else {
reject(new Error('User not found'));
}
@ -146,6 +144,7 @@ async function getExtId(req) {
if (mUser) {
// Return a Response with the whole identifiable user data. the EXT_ID will be used later to identify images and other things and match them to the user's profile.
resolve(mUser);
con.release();
} else {
reject(new Error('User not found'));
}
@ -199,6 +198,7 @@ async function getUserScores(req) {
}
// Return a Response with all the Scores listed under that user.
resolve(mUser)
con.release();
})
});
}
@ -228,7 +228,6 @@ async function getUserArea(req) {
});
});
} else {
return new Promise((resolve, reject) => {
con.query("SELECT * FROM aime.mai2_item_map", function (err, result, fields) {
if (err) {
@ -250,6 +249,7 @@ async function getUserArea(req) {
}
// Return a Response with all the Scores listed under that user.
resolve(mUser)
con.release();
})
});
}

View File

@ -9,7 +9,7 @@ var indexRouter = require('./routes/index');
var apiRouter = require('./routes/api');
var config = require("./config.json");
if (config.serverType === 0) { // Only run the image Importer when Aqua is active
if (config.serverType === 0) { // Only run the image Importer with aqua or when given Artemis Settings for it)
const watcher = chokidar.watch(config.aquaSrvDir, {
persistent: true
});
@ -62,6 +62,10 @@ if (config.serverType === 0) { // Only run the image Importer when Aqua is activ
} else {
console.log("Image Export Disabled. Check readme.md for details.")
}
if(config.serverType === 1 && !config.ArtConnSettings.connectionLimit) {
console.error("You are Missing the `ConnectionLimit` setting. Please add and set it in config.json.");
process.exit(1);
}
// readFileSync function must use __dirname get current directory
// require use ./ refer to current directory.

View File

@ -68,6 +68,7 @@ Create a `config.json` file and paste this in, with paths to your instance.
"ArtImageImport": true,
"ArtImageDirectory":"S:\\Artemis\\Server\\Image\\Directory",
"ArtConnSettings": {
"connectionLimit": "2",
"host":"192.168.smt.hng",
"user":"MaiDXNet",
"pass":"aSecurePassword"