Created
October 13, 2020 09:21
-
-
Save erossignon/88d73c43bba876012800e0f1c07163ea to your computer and use it in GitHub Desktop.
simple script to get OPCUA server endpoint
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### how to use | |
node getEndpointBasic.js opc.tcp://opcuademo.sterfive.com:26543 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const { OPCUAClient, SecurityPolicy, MessageSecurityMode } = require("node-opcua"); | |
const endpointUri = process.argv[2] || "opc.tcp://opcuademo.sterfive.com:26543"; | |
(async () => { | |
try { | |
console.log("connecting to ", endpointUri); | |
const client = OPCUAClient.create({ endpoint_must_exist: false }); | |
client.on("backoff", () => { | |
console.log("still connecting ", endpointUri); | |
}) | |
await client.connect(endpointUri); | |
const endpoints = await client.getEndpoints(); | |
for (const endpoint of endpoints) { | |
console.log( | |
endpoint.endpointUrl.padEnd(40), | |
endpoint.securityPolicyUri.padEnd(60), | |
MessageSecurityMode[endpoint.securityMode] | |
); | |
} | |
await client.disconnect(); | |
} | |
catch (err) { | |
console.log(err.message); | |
process.exit(); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment