Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

closing modbus connection using close() and it will crashing my electron app #553

Open
Bhargav2patel opened this issue May 2, 2024 · 1 comment

Comments

@Bhargav2patel
Copy link

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);
    }
}
@teddy1565
Copy link
Contributor

can you provide full code? I intuitively think this is more likely because you are not familiar with the Electron development framework.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants