private getChargingStationId(stationTemplate: ChargingStationTemplate): string {
// In case of multiple instances: add instance index to charging station id
- let instanceIndex = process.env.CF_INSTANCE_INDEX ?? 0;
- instanceIndex = instanceIndex > 0 ? instanceIndex : '';
+ const instanceIndex = process.env.CF_INSTANCE_INDEX ?? 0;
const idSuffix = stationTemplate.nameSuffix ?? '';
return stationTemplate.fixedName ? stationTemplate.baseName : stationTemplate.baseName + '-' + instanceIndex.toString() + ('000000000' + this.index.toString()).substr(('000000000' + this.index.toString()).length - 4) + idSuffix;
}
this.hasSocketRestarted = false;
}
- private async onClose(code: number): Promise<void> {
+ private async onClose(code: number, reason: string): Promise<void> {
switch (code) {
- case WebSocketCloseEventStatusCode.CLOSE_NORMAL: // Normal close
+ // Normal close
+ case WebSocketCloseEventStatusCode.CLOSE_NORMAL:
case WebSocketCloseEventStatusCode.CLOSE_NO_STATUS:
- logger.info(`${this.logPrefix()} Socket normally closed with status '${Utils.getWebSocketCloseEventStatusString(code)}'`);
+ logger.info(`${this.logPrefix()} Socket normally closed with status '${Utils.getWebSocketCloseEventStatusString(code)}' and reason '${reason}'`);
this.autoReconnectRetryCount = 0;
break;
- default: // Abnormal close
- logger.error(`${this.logPrefix()} Socket abnormally closed with status '${Utils.getWebSocketCloseEventStatusString(code)}'`);
+ // Abnormal close
+ default:
+ logger.error(`${this.logPrefix()} Socket abnormally closed with status '${Utils.getWebSocketCloseEventStatusString(code)}' and reason '${reason}'`);
await this.reconnect(code);
break;
}