Clean-up current transaction when Start Transaction fails
MODIFY
src/server/ocpp/services/OCPPService.ts
src/server/ocpp/services/OCPPService.ts
@@ -471,6 +471,12 @@ export default class OCPPService {
status: OCPPAuthorizationStatus.ACCEPTED
}
};
+ } catch (error) {
+ // Cleanup ongoing Transaction
+ await this.stopOrDeleteActiveTransaction(tenant, chargingStation, startTransaction.connectorId);
+ // Save
+ await ChargingStationStorage.saveChargingStation(tenant, chargingStation);
+ throw error;
} finally {
// Release lock
await LockingManager.release(chargingStationLock);
@@ -787,7 +793,7 @@ export default class OCPPService {
let foundConnector = Utils.getConnectorFromID(chargingStation, statusNotification.connectorId);
if (!foundConnector) {
// Check backup first
- foundConnector = Utils.getBackupConnectorFromID(chargingStation, statusNotification.connectorId);
+ foundConnector = Utils.getLastSeenConnectorFromID(chargingStation, statusNotification.connectorId);
if (foundConnector) {
// Append the backup connector
chargingStation.connectors.push(foundConnector);

MODIFY
src/utils/Utils.ts
src/utils/Utils.ts
@@ -538,7 +538,7 @@ export default class Utils {
return chargingStation.connectors.find((connector) => connector && (connector.connectorId === connectorID));
}
- public static getBackupConnectorFromID(chargingStation: ChargingStation, connectorID: number): Connector {
+ public static getLastSeenConnectorFromID(chargingStation: ChargingStation, connectorID: number): Connector {
if (!chargingStation.backupConnectors) {
return null;
}

Clean-up current transaction when Start Transaction fails