Comments (3)
While debugging the code, I observed that in the 'result' parameter of the callback, which is passed as an argument to this.translateBrowsePath
, the StatusCode is:
statusCode: BadNodeIdUnknown (0x80340000) {
_description: 'The node id refers to a node that does not exist in the server address space.',
_name: 'BadNodeIdUnknown',
_value: 2150891520,
}
from node-opcua.
I successfully acknowledged the alarm by employing a different method, which I discovered in a node-opcua issue discussion:
How to acknowledge alarm using Cogent DataHub #1317
However, the standard or 'correct' method for event acknowledgment proved entirely ineffective in my case. Consequently, it's fair to conclude that this issue remains unresolved.
This situation is particularly puzzling since I've been providing precisely the same parameters that worked with session.acknowledgeCondition
.
Here's how the code currently stands:
Additionally, I am eager to share the complete code for the benefit of anyone looking to implement a similar solution.
import express from "express";
import { createServer } from 'node:http'
import { AttributeIds, OPCUAClient, TimestampsToReturn, constructEventFilter, ObjectIds, callConditionRefresh, MethodIds, Variant, DataType } from "node-opcua-client";
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 = {
}
callConditionRefresh(subscripcion) // Give us all events!!!
EventMonitor.on("changed", (events) => {
for (let i = 0; i < events.length; i++) {
alarmData[fields[i]] = events[i].value
}
console.log(alarmData)
});
setTimeout(async () => {
try {
/* session.acknowledgeCondition(alarmData.ConditionId, alarmData.EventId, comment, (err) => {
console.log({ err })
}) */
const methodToCall = {
objectId: alarmData.ConditionId,
methodId: MethodIds.AcknowledgeableConditionType_Acknowledge, // TODO: Replace to MethodIds
inputArguments: [
new Variant({ dataType: DataType.ByteString, value: alarmData.EventId }),
new Variant({ dataType: DataType.LocalizedText, value: "test comment!" })
]
}
session.call(methodToCall, (err, result) => {
if (err) return console.log(err); // Currently not important
console.log("Method call result: " + JSON.stringify(result, null, 2));
})
} 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');
});
})();
from node-opcua.
It should be fixed now in [email protected].
@AcureroAdrian can you confirm ?
from node-opcua.
Related Issues (20)
- MultiStateValueDiscrete_ValueAsText gives "Invalid" when Variable value is 0 HOT 2
- Node-opcua inherits variables from objectType with same name as variable browseName. HOT 4
- Unable to retrieve the description from KEPServerEX. HOT 1
- Delay after connection_reestablished before OPCUAClient.isReconnecting is back to false HOT 4
- Allow the nodeIdNameSeparator in the NamespaceOptions of the node-opcua-address-space to be configurable HOT 2
- Client is connected but no more changes are retrived from monitored items after some hours HOT 13
- [NODE-OPCUA-E11] message size 16385 exceeds the negotiated message size 16384 nb chunks 1. HOT 9
- Timestamps not updating in latest versions HOT 1
- Slow require time in jest HOT 3
- After updating node-opcua, an error during client.createSession process occurs. Old versions works fine. HOT 4
- Difference in clocks between client and server cause problems HOT 4
- Loading nodeset files via string/stream/..
- maxStringLength HOT 3
- After writing scripts no longer worked, stopping connection
- nodeopcua Client fails when "certificate" User authentication is used.
- node-opcua Client does not retry connection ,when server is not available , when security Policy other than NONE is used HOT 1
- AWS Lambda cannot create PKI folder for opcua-client
- Client fails to generate default certificate when connecting to server in Electron main process.
- notification in server HOT 2
- node-opcua server has problems handling nodeset file containing UAVariable of DataType="RolePermissionType
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from node-opcua.