node-modbus-serial
node-modbus-serial copied to clipboard
closing modbus connection using close() and it will crashing my electron app
making an electron app and using modbus serial package,
connected the modubus client and readed holding register succesfully and when i am trying to redirect to onether page using javascripts window.onbeforeunload function and closing client connection from inside this function ,
but the problem is this will crashing my electron app but the logs of rediraction will be printed succesfully when the client disconnect
const $ = require('jquery');
const ModbusRTU = require("modbus-serial");
var client = new ModbusRTU();
$(document).ready(function () {
$("#print-menu").click(function () {
window.location.href = 'print-menu.html';
})
});
window.onbeforeunload = function () {
try {
logger.info("redirecting");
client.close();
logger.info("redirected");
} catch (error) {
logger.error(error);
}
}
can you provide full code? I intuitively think this is more likely because you are not familiar with the Electron development framework.