[EMSP] Fix callback url of remote start command
MODIFY
src/client/ocpi/EmspOCPIClient.ts
src/client/ocpi/EmspOCPIClient.ts
@@ -494,6 +494,7 @@ export default class EmspOCPIClient extends OCPIClient {
async remoteStartSession(chargingStation: ChargingStation, connectorId: number, tagId: string): Promise<OCPICommandResponse> {
// Get command endpoint url
const commandUrl = this.getEndpointUrl('commands', ServerAction.OCPI_START_SESSION) + '/' + OCPICommandType.START_SESSION;
+ const callbackUrl = this.getLocalEndpointUrl('commands') + '/' + OCPICommandType.START_SESSION;
const user = await UserStorage.getUserByTagId(this.tenant.id, tagId);
if (!user || user.deleted || !user.issuer) {
throw new BackendError({
@@ -528,7 +529,7 @@ export default class EmspOCPIClient extends OCPIClient {
const authorizationId = uuid();
const payload: OCPIStartSession = {
// eslint-disable-next-line @typescript-eslint/camelcase
- response_url: commandUrl + '/' + uuid(),
+ response_url: callbackUrl + '/' + authorizationId,
token: token,
// eslint-disable-next-line @typescript-eslint/camelcase
evse_uid: chargingStation.imsi,

MODIFY
src/client/ocpi/OCPIClient.ts
src/client/ocpi/OCPIClient.ts
@@ -11,6 +11,7 @@ import { OcpiSetting } from '../../types/Setting';
import { ServerAction } from '../../types/Server';
import Tenant from '../../types/Tenant';
import axios from 'axios';
+import Configuration from '../../utils/Configuration';
const MODULE_NAME = 'OCPIClient';
@@ -308,7 +309,7 @@ export default abstract class OCPIClient {
return this.settings[this.role].partyID;
}
- protected getEndpointUrl(service, action: ServerAction) {
+ protected getEndpointUrl(service: string, action: ServerAction): string {
if (this.ocpiEndpoint.availableEndpoints) {
return this.ocpiEndpoint.availableEndpoints[service];
}
@@ -318,5 +319,9 @@ export default abstract class OCPIClient {
});
}
+ protected getLocalEndpointUrl(service: string): string {
+ return `${Configuration.getOCPIEndpointConfig().baseUrl}/ocpi/${this.role}/${this.ocpiEndpoint.version}/${service}`;
+ }
+
async abstract triggerJobs();
}

[EMSP] Fix callback url of remote start command