Added error handling
This commit is contained in:
parent
dbd77dde34
commit
e9c9ca8d34
@ -50,6 +50,7 @@ class RconManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async connect(server_id, server) {
|
async connect(server_id, server) {
|
||||||
|
try {
|
||||||
let rcon_connection = null;
|
let rcon_connection = null;
|
||||||
rcon_connection = new Rcon({ host: server.serverIP, port: server.serverPort, timeout: 5000 });
|
rcon_connection = new Rcon({ host: server.serverIP, port: server.serverPort, timeout: 5000 });
|
||||||
console.log("CONNECTING RCON", server_id, server.serverIP, server.serverPort);
|
console.log("CONNECTING RCON", server_id, server.serverIP, server.serverPort);
|
||||||
@ -72,7 +73,6 @@ class RconManager {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
clearTimeout(authenticationTimeout);
|
clearTimeout(authenticationTimeout);
|
||||||
console.error('RCON Authentication failed', server_id, error);
|
console.error('RCON Authentication failed', server_id, error);
|
||||||
// Handle the authentication error here as needed.
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.rcons[server_id] = rcon_connection;
|
this.rcons[server_id] = rcon_connection;
|
||||||
@ -83,8 +83,13 @@ class RconManager {
|
|||||||
connected: rcon_connection.isConnected(),
|
connected: rcon_connection.isConnected(),
|
||||||
authenticated: rcon_connection.isAuthenticated()
|
authenticated: rcon_connection.isAuthenticated()
|
||||||
};
|
};
|
||||||
|
if (rcon_connection.isConnected() && rcon_connection.isAuthenticated()) {
|
||||||
this.details[server_id].heartbeat_interval = setInterval(async () => this.send_heartbeat(server_id, server), 5000);
|
this.details[server_id].heartbeat_interval = setInterval(async () => this.send_heartbeat(server_id, server), 5000);
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
} catch (error) {
|
||||||
|
console.error('[CONNECTION ERROR]', error);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async disconnect_rcon(server_id) {
|
async disconnect_rcon(server_id) {
|
||||||
|
@ -282,6 +282,7 @@ function execute_cfg_on_server(server_id, cfg_path) {
|
|||||||
const exported_lines = splitByByteLength(data, 512)
|
const exported_lines = splitByByteLength(data, 512)
|
||||||
|
|
||||||
function execute_next_item(item) {
|
function execute_next_item(item) {
|
||||||
|
try {
|
||||||
if (item < exported_lines.length) {
|
if (item < exported_lines.length) {
|
||||||
console.log(exported_lines[item]);
|
console.log(exported_lines[item]);
|
||||||
rcon.rcons[server_id].execute(exported_lines[item]);
|
rcon.rcons[server_id].execute(exported_lines[item]);
|
||||||
@ -291,6 +292,9 @@ function execute_cfg_on_server(server_id, cfg_path) {
|
|||||||
execute_next_item(item + 1);
|
execute_next_item(item + 1);
|
||||||
}, 200);
|
}, 200);
|
||||||
}
|
}
|
||||||
|
} catch (error) {
|
||||||
|
console.log("[execute_next_item] Error:", error)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
execute_next_item(0);
|
execute_next_item(0);
|
||||||
});
|
});
|
||||||
|
Loading…
Reference in New Issue
Block a user