Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Node.js Ocpp memory leak

I want to create OCPP JSON central system in Node.js. For OCPP 1.6 implementation, there are packages with good examples. But for OCPP2.0 I’ve found only ocpp-rpc and faced huge memory leaks on high number of connections. Is there any others packages? Thanks

That’s what i’ve tried:

const server = new RPCServer({
        protocols: ['ocpp2.0.1'],
        strictMode: true,
    });

    server.auth((accept, reject, handshake) => {
        accept({
            sessionId: 'XYZ123'
        });
    });

    server.on('client', async (client) => {
        client.handle('BootNotification', ({params}) => {
            return {
                status: "Accepted",
                interval: 300,
                currentTime: new Date().toISOString()
            };
        });
    });
    await server.listen(3000);

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

Try @extrawest/node-ts-ocpp

Your implementation will look like

const centralSystemSimple = new OcppServer();
centralSystemSimple.listen(parseInt(process.env.PORT) || 3000);
centralSystemSimple.on('connection', (client: OcppClientConnection) => {
    client.on('BootNotification', (request: BootNotificationRequest, cb: (response: BootNotificationResponse) => void) => {
        const response: BootNotificationResponse = {
            status: 'Accepted',
            currentTime: new Date().toISOString(),
            interval: parseInt(process.env.HEARTBEAT_INTERVAL),
        };
        cb(response);
    });
});
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading