Log WS message parsing
MODIFY
src/server/ocpp/json/JsonCentralSystemServer.ts
src/server/ocpp/json/JsonCentralSystemServer.ts
@@ -361,9 +361,10 @@ export default class JsonCentralSystemServer extends CentralSystemServer {
}
private async onMessage(ws: uWS.WebSocket, message: string, isBinary: boolean): Promise<void> {
+ const wsWrapper: WSWrapper = ws.wsWrapper;
+ try {
// Convert
const [ocppMessageType] = JSON.parse(message);
- const wsWrapper = ws.wsWrapper;
// Lock incoming WS messages
await this.aquireLockForWSRequest(wsWrapper, ocppMessageType);
try {
@@ -390,6 +391,15 @@ export default class JsonCentralSystemServer extends CentralSystemServer {
this.runningWSMessages--;
this.releaseLockForWSMessageRequest(wsWrapper, ocppMessageType);
}
+ } catch (error) {
+ await Logging.logError({
+ ...LoggingHelper.getWSWrapperProperties(wsWrapper),
+ action: ServerAction.WS_MESSAGE,
+ module: MODULE_NAME, method: 'processTransactionRoaming',
+ message: `Error occurred: ${error.message as string}`,
+ detailedMessages: { message, isBinary, error: error.stack }
+ });
+ }
}
private async getWSConnectionFromWebSocket(wsWrapper: WSWrapper, closeWSIfNotFound = true): Promise<WSConnection> {

MODIFY
src/types/Server.ts
src/types/Server.ts
@@ -237,6 +237,7 @@ export enum ServerAction {
WS_CLIENT_INFO = 'WSClientInfo',
WS_CONNECTION = 'WSConnection',
+ WS_MESSAGE = 'WSMessage',
WS_CONNECTION_PINGED = 'WSConnectionPinged',
WS_CONNECTION_OPENED = 'WSConnectionOpened',
WS_CONNECTION_CLOSED = 'WSConnectionClosed',

MODIFY
src/utils/LoggingHelper.ts
src/utils/LoggingHelper.ts
@@ -4,6 +4,7 @@ import Site from '../types/Site';
import SiteArea from '../types/SiteArea';
import Transaction from '../types/Transaction';
import User from '../types/User';
+import WSWrapper from '../server/ocpp/json/WSWrapper';
export default class LoggingHelper {
@@ -26,6 +27,16 @@ export default class LoggingHelper {
};
}
+ public static getWSWrapperProperties(wsWrapper: WSWrapper): { tenantID: string; siteID: string; siteAreaID: string; companyID: string; chargingStationID: string; } {
+ return {
+ tenantID: wsWrapper.tenantID,
+ siteID: wsWrapper.siteID,
+ siteAreaID: wsWrapper.siteAreaID,
+ companyID: wsWrapper.companyID,
+ chargingStationID: wsWrapper.chargingStationID,
+ };
+ }
+
public static getAssetProperties(asset: Asset): { siteID: string; siteAreaID: string; } {
return {
siteID: asset.siteID,

Log WS message parsing