Remove locking on WS connection
MODIFY
src/locking/LockingHelper.ts
src/locking/LockingHelper.ts
@@ -192,15 +192,6 @@ export default class LockingHelper {
return lock;
}
- public static async acquireChargingStationConnectionLock(tenantID: string): Promise<Lock | null> {
- const lock = LockingManager.createExclusiveLock(tenantID, LockEntity.CHARGING_STATION,
- 'json-connection', Constants.CHARGING_STATION_CONNECTION_LOCK_SECS);
- if (!(await LockingManager.acquire(lock, Constants.CHARGING_STATION_CONNECTION_LOCK_SECS * 2))) {
- return null;
- }
- return lock;
- }
-
private static async acquireOCPIEndpointActionLock(tenantID: string, ocpiEndpoint: OCPIEndpoint, action: string): Promise<Lock | null> {
const lock = LockingManager.createExclusiveLock(tenantID, LockEntity.OCPI_ENDPOINT, `${ocpiEndpoint.id}-${action}`);
if (!(await LockingManager.acquire(lock))) {

MODIFY
src/server/ocpp/json/WSConnection.ts
src/server/ocpp/json/WSConnection.ts
@@ -59,17 +59,6 @@ export default abstract class WSConnection {
}
public async initialize(): Promise<void> {
- // Control the number of Json connections
- const chargingStationConnectionLock = await LockingHelper.acquireChargingStationConnectionLock(this.getTenantID());
- if (!chargingStationConnectionLock) {
- throw new BackendError({
- chargingStationID: this.getChargingStationID(),
- module: MODULE_NAME, method: 'initialize',
- message: 'Cannot acquire a lock on the Charging Station\'s connection'
- });
- }
- // Proceed with the connection handling
- try {
if (!this.initialized) {
// Check and Get Charging Station data
const { tenant, chargingStation } = await OCPPUtils.checkAndGetChargingStationData(
@@ -78,10 +67,6 @@ export default abstract class WSConnection {
this.setTenant(tenant);
this.setChargingStation(chargingStation);
}
- } finally {
- // Release the lock
- await LockingManager.release(chargingStationConnectionLock);
- }
}
public async onMessage(messageEvent: MessageEvent): Promise<void> {

Remove locking on WS connection