From c52f1f49e485e8f75682f5ce974d54144cbe2b7c Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=B4me=20Benoit?= Date: Fri, 1 Oct 2021 21:15:20 +0200 Subject: [PATCH] Do not log response statistics at sending issues MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérôme Benoit --- src/charging-station/ocpp/OCPPRequestService.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/charging-station/ocpp/OCPPRequestService.ts b/src/charging-station/ocpp/OCPPRequestService.ts index a8567b4d..f3f64514 100644 --- a/src/charging-station/ocpp/OCPPRequestService.ts +++ b/src/charging-station/ocpp/OCPPRequestService.ts @@ -48,10 +48,10 @@ export default abstract class OCPPRequestService { // Reject it but keep the request in the cache return reject(ocppError); } - return rejectCallback(ocppError); + return rejectCallback(ocppError, false); } else { // Reject it - return rejectCallback(new OCPPError(ErrorType.GENERIC_ERROR, `WebSocket closed for non buffered message id '${messageId}' with content '${messageToSend}'`, commandParams?.details ?? {})); + return rejectCallback(new OCPPError(ErrorType.GENERIC_ERROR, `WebSocket closed for non buffered message id '${messageId}' with content '${messageToSend}'`, commandParams?.details ?? {}), false); } // Response? if (messageType !== MessageType.CALL_MESSAGE) { @@ -59,7 +59,7 @@ export default abstract class OCPPRequestService { resolve(commandParams); } else { // Send timeout - setTimeout(() => rejectCallback(new OCPPError(ErrorType.GENERIC_ERROR, `Timeout for message id '${messageId}' with content '${messageToSend}'`, commandParams?.details ?? {})), Constants.OCPP_SOCKET_TIMEOUT); + setTimeout(() => rejectCallback(new OCPPError(ErrorType.GENERIC_ERROR, `Timeout for message id '${messageId}' with content '${messageToSend}'`, commandParams?.details ?? {}), false), Constants.OCPP_SOCKET_TIMEOUT); } /** @@ -82,9 +82,10 @@ export default abstract class OCPPRequestService { * Function that will receive the request's error response * * @param error + * @param requestStatistic */ - function rejectCallback(error: OCPPError): void { - if (self.chargingStation.getEnableStatistics()) { + function rejectCallback(error: OCPPError, requestStatistic = true): void { + if (requestStatistic && self.chargingStation.getEnableStatistics()) { self.chargingStation.performanceStatistics.addRequestStatistic(commandName, MessageType.CALL_ERROR_MESSAGE); } logger.error(`${self.chargingStation.logPrefix()} Error %j occurred when calling command %s with parameters %j`, error, commandName, commandParams); -- 2.34.1