import OCPPError from './OCPPError';
import OCPPResponseService from './OCPPResponseService';
import PerformanceStatistics from '../../performance/PerformanceStatistics';
import OCPPError from './OCPPError';
import OCPPResponseService from './OCPPResponseService';
import PerformanceStatistics from '../../performance/PerformanceStatistics';
const messageToSend = this.buildMessageToSend(messageId, commandParams, messageType, commandName, responseCallback, rejectCallback);
if (this.chargingStation.getEnableStatistics()) {
this.chargingStation.performanceStatistics.addRequestStatistic(commandName, messageType);
const messageToSend = this.buildMessageToSend(messageId, commandParams, messageType, commandName, responseCallback, rejectCallback);
if (this.chargingStation.getEnableStatistics()) {
this.chargingStation.performanceStatistics.addRequestStatistic(commandName, messageType);
PerformanceStatistics.endMeasure(commandName, beginId);
} else if (!skipBufferingOnError) {
// Buffer it
PerformanceStatistics.endMeasure(commandName, beginId);
} else if (!skipBufferingOnError) {
// Buffer it
const ocppError = new OCPPError(ErrorType.GENERIC_ERROR, `WebSocket closed for buffered message id '${messageId}' with content '${messageToSend}'`, commandParams?.details ?? {});
if (messageType === MessageType.CALL_MESSAGE) {
// Reject it but keep the request in the cache
const ocppError = new OCPPError(ErrorType.GENERIC_ERROR, `WebSocket closed for buffered message id '${messageId}' with content '${messageToSend}'`, commandParams?.details ?? {});
if (messageType === MessageType.CALL_MESSAGE) {
// Reject it but keep the request in the cache
+ }), Constants.OCPP_WEBSOCKET_TIMEOUT, new OCPPError(ErrorType.GENERIC_ERROR, `Timeout for message id '${messageId}'`, commandParams?.details ?? {}), () => {
+ messageType === MessageType.CALL_MESSAGE && this.chargingStation.requests.delete(messageId);