}
throw new OCPPError(
ErrorType.PROTOCOL_ERROR,
- `Cached request for message id ${messageId} ${getMessageTypeString(
+ `Cached request for message id '${messageId}' ${getMessageTypeString(
messageType
)} is not an array`,
undefined,
private async handleIncomingMessage (request: IncomingRequest): Promise<void> {
const [messageType, messageId, commandName, commandPayload] = request
+ if (this.requests.has(messageId)) {
+ throw new OCPPError(
+ ErrorType.SECURITY_ERROR,
+ `Received message with duplicate message id '${messageId}'`,
+ commandName,
+ commandPayload
+ )
+ }
if (this.stationInfo?.enableStatistics === true) {
this.performanceStatistics?.addRequestStatistic(commandName, messageType)
}
// Error
throw new OCPPError(
ErrorType.INTERNAL_ERROR,
- `Response for unknown message id ${messageId}`,
+ `Response for unknown message id '${messageId}'`,
undefined,
commandPayload
)
// Error
throw new OCPPError(
ErrorType.INTERNAL_ERROR,
- `Error response for unknown message id ${messageId}`,
+ `Error response for unknown message id '${messageId}'`,
undefined,
{ errorType, errorMessage, errorDetails }
)
}
if (!(error instanceof OCPPError)) {
logger.warn(
- `${this.logPrefix()} Error thrown at incoming OCPP command '${
+ `${this.logPrefix()} Error thrown at incoming OCPP command ${
commandName ?? requestCommandName ?? Constants.UNKNOWN_OCPP_COMMAND
// eslint-disable-next-line @typescript-eslint/no-base-to-string
- }' message '${data.toString()}' handling is not an OCPPError:`,
+ } message '${data.toString()}' handling is not an OCPPError:`,
error
)
}
// OCPPError usage here is debatable: it's an error in the OCPP stack but not targeted to sendError().
throw new OCPPError(
ErrorType.NOT_SUPPORTED,
- `Unsupported OCPP command '${commandName}'`,
+ `Unsupported OCPP command ${commandName}`,
commandName,
commandParams
)
throw new OCPPError(
ErrorType.NOT_SUPPORTED,
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
- `Unsupported OCPP command '${commandName}'`,
+ `Unsupported OCPP command ${commandName}`,
commandName,
commandParams
)
// OCPPError usage here is debatable: it's an error in the OCPP stack but not targeted to sendError().
throw new OCPPError(
ErrorType.NOT_SUPPORTED,
- `Unsupported OCPP command '${commandName}'`,
+ `Unsupported OCPP command ${commandName}`,
commandName,
commandParams
)
throw new OCPPError(
ErrorType.NOT_SUPPORTED,
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
- `Unsupported OCPP command '${commandName}'`,
+ `Unsupported OCPP command ${commandName}`,
commandName,
commandParams
)