Log also ws closing reason
[e-mobility-charging-stations-simulator.git] / src / charging-station / ChargingStation.ts
index 72c781fc4ddf2b1a8b10b68f21c067ccb8ab938f..103a96f0bdc970b003169adccb801009a4d1c57b 100644 (file)
@@ -631,15 +631,17 @@ export default class ChargingStation {
     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;
     }