Fix issue where client sessions were closed without status updates

This commit is contained in:
David Majdandžić
2023-03-27 16:40:54 +02:00
parent 96b0257c1d
commit 2e09392627

View File

@@ -212,6 +212,7 @@ class ClientSession {
auto_enquire_link_period: this.auto_enquire_link_period, auto_enquire_link_period: this.auto_enquire_link_period,
}, this.connected.bind(this)); }, this.connected.bind(this));
this.session.on('error', this.error.bind(this)); this.session.on('error', this.error.bind(this));
this.session.on('close', this.closed.bind(this));
} catch (e) { } catch (e) {
this.logger.log1("Client connection failed to " + this.url); this.logger.log1("Client connection failed to " + this.url);
this.setStatus(ClientSessionStatus.NOT_CONNECTED); this.setStatus(ClientSessionStatus.NOT_CONNECTED);
@@ -224,6 +225,11 @@ class ClientSession {
return this.connectingPromise.promise; return this.connectingPromise.promise;
} }
closed() {
this.logger.log1(`Client closed connection to ${this.url}`);
this.setStatus(ClientSessionStatus.NOT_CONNECTED);
}
error(error) { error(error) {
if (error.code === "ETIMEOUT") { if (error.code === "ETIMEOUT") {
this.logger.log1("Client connection timed out to " + this.url); this.logger.log1("Client connection timed out to " + this.url);