From: Jérôme Benoit Date: Fri, 1 Oct 2021 19:15:20 +0000 (+0200) Subject: Do not log response statistics at sending issues X-Git-Tag: v1.1.21~1 X-Git-Url: https://git.piment-noir.org/?a=commitdiff_plain;h=c52f1f49e485e8f75682f5ce974d54144cbe2b7c;p=e-mobility-charging-stations-simulator.git Do not log response statistics at sending issues Signed-off-by: Jérôme Benoit --- 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);