Node-OPCUA Issue: ‘Acknowledge Method Not Found’ Error with Alarm Acknowledgment Functions

I am working with Node-OPCUA as an OPC UA client to interact with a Codesys PLC. I’m using node-opcua version 2.115.0 on an ASUS ZenBook, running Windows 11 Pro, version 10.0.22631 Build 22631. My goal is to acknowledge and confirm alarms from my OPC UA server.

• Current Problem:

I successfully connect to my local Codesys PLC, can see and modify values, and view alarms and their current status. However, when trying to use the acknowledgeCondition or confirmCondition functions to acknowledge an alarm, I encounter an error stating: “Error: cannot find Acknowledge Method”. This is perplexing as I am passing the same values (‘ConditionId’ and ‘EventId’) that EventMonitor.on() provides me.

Expected Behavior:

The alarms should be acknowledged and reflected in my Codesys PLC. With UAExpert, I can see my alarms and acknowledge and confirm them without issues, leading me to believe the error lies within node-opcua.

Code:
`

    import express from "express";
    import { createServer } from 'node:http';
    import { AttributeIds, OPCUAClient, TimestampsToReturn, constructEventFilter, ObjectIds } from "node-opcua";
                                                                                              
    const app = express();
    const server = createServer(app);

    const URL = "opc.tcp://ADRIAN-ASUS:4840";

    (async () => {
    try {
         const client = OPCUAClient.create();
        client.on("backoff", (retry, delay) => {
         console.log("Retying to connect to ", URL, " attempt ", retry);
        });
   
    console.log("connecting to ", URL);
    await client.connect(URL);
    console.log("connected to ", URL);

   const session = await client.createSession();
    console.log("session initialized");

    const subscripcion = await session.createSubscription2({
        requestedPublishingInterval: 50,
        requestedMaxKeepAliveCount: 20,
        publishingEnabled: true,
    });

    const fields = [
        "EventId",
        "AckedState",
        "AckedState.Id",
        "ConfirmedState",
        "ConfirmedState.Id",
        "ConditionId",
    ];

    const eventFilter = constructEventFilter(fields);

    const itemToMonitor = {
        nodeId: ObjectIds.Server,
        attributeId: AttributeIds.EventNotifier,
    };

    const parameters = {
        filter: eventFilter,
        discardOldest: true,
        queueSize: 100,
    };

    const EventMonitor = await subscripcion.monitor(
        itemToMonitor,
        parameters,
        TimestampsToReturn.Both
    )

    const alarmData = {
    }

    EventMonitor.on("changed", (events) => {
        for (let i = 0; i < events.length; i++) {
            alarmData[fields[i]] = events[i].value
        }
    });

    setTimeout( async () => {

        try {
            const comment = 'Comment random';

            console.log({conditionId: alarmData.ConditionId, eventId: alarmData.EventId})

            session.acknowledgeCondition(alarmData.ConditionId, alarmData.EventId, comment, (err) => {
                console.log({ err })
            }) 
        } catch (error) {
            console.log(error)
        }

    }, 5000)



    let running = true;
    process.on("SIGINT", async () => {
        if (!running) {
            return; // avoid calling shutdown twice
        }
        console.log("shutting down client");
        running = false;
        await subscripcion.terminate();
        await session.close();
        await client.disconnect();
        console.log("Done");
        process.exit(0);
    });
} catch (error) {
    console.log("ERROR: ", error.message);
    console.log(error);
}

server.listen(4000, () => {
    console.log('server running at http://localhost:4000');
})
     })()`

• Errors and Logs:

Error when attempting to acknowledge the alarm:
Error Log

Output of console.log showing the ‘conditionId’ and ‘eventId’ values:
Console.log conditionId and eventId data

Additional Information:

• I have installed node-opcua as a package using npm.
• Using Node 20.10.0
• I am attempting to connect to an OPCUA system: CODESYS Control Win V3 x64, version 3.5.19.3 (x64).

Try downloading all the previous versions of node.