Closed black-hawk85 closed 3 years ago
@black-hawk85 you can catch login fails with x.onReject callback and then you can disconnect with x.disconnect
Ya, that's exactly what I tried. That is where the error 'Not logged - logout' (BE103) comes in and spams my error log. Strange thing is that the disconnect's promise won't get resolved if I try to await it.
Here's some test code
Catching and printing unhandled exceptions
process.on('unhandledRejection', (reason, p) => {
if (reason.reason && reason.reason.code && reason.reason.explain) {
console.log("unhandledRejection: " + reason.reason.explain + "(" + reason.reason.code + ")")
}
});
Connecting with wrong login data
options.password = "1234"
this.connector = new XAPI(options);
this.connector.connect(); // if login data is incorrect we'll get keep getting unhandledRejection which we cannot catch
this.connector.onReject(async err => {
await this.connector.disconnect();
console.log(e + " => disconnected") // this line is never reached
})
This is my output
unhandledRejection: Not logged - logout(BE103)
unhandledRejection: Socket closed(XAPINODE_1)
unhandledRejection: Not logged - logout(BE103)
unhandledRejection: Socket closed(XAPINODE_1)
unhandledRejection: Not logged - logout(BE103)
unhandledRejection: Socket closed(XAPINODE_1)
unhandledRejection: Not logged - logout(BE103)
unhandledRejection: Socket closed(XAPINODE_1)
....
@black-hawk85 I pushed a new version can you try it ?
Yesss, this looks good now ;) thanks for the quick fix! Will test a little more in detail when I have more time but I think this fixes the issue
@black-hawk85 problem not solved :D I found another stuff related to this :D
okay I solved it, if you find another bug just create an issue.
Sorry to bother again but I'm having trouble with accounts which fail to login (e.g. expired demo accounts or when entered wrong password).
They try to reconnect all the time even when I call disconnect method. On the contrary, when I call disconnect method after failed login I keep getting uncaught exception 'Not logged - logout' (BE103)
I have a doubt that this may lead to memory leaks.
Is there a way to disable tryReconnect or stop reconnecting and close the socket after calling disconnect even when authentication was unsuccessful?