Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

110
Views
How to add new Variable dynamically after OPC-UA has started from client side

I have an OPC-UA server up and running with some pre-configured tags, now I want to add a new Variable from my NodeJS OPC-UA client when my certain tag changes. For e.g.

import {
    OPCUAClient,
    MessageSecurityMode, SecurityPolicy,
    AttributeIds,
 } from "node-opcua-client";

const connectionStrategy = {
    initialDelay: 1000,
    maxRetry: 1
}

const options = {
    applicationName: "MyClient",
    connectionStrategy: connectionStrategy,
    securityMode: MessageSecurityMode.SignAndEncrypt,
    securityPolicy: SecurityPolicy.Basic256Sha256,
    endpointMustExist: false,
    
};
const client = OPCUAClient.create(options);
const endpointUrl = "{opc_url}";

try {
      // step 1 : connect to
      await client.connect(endpointUrl).then(res => console.log('connected!'))
    //   console.log("connected !");
  
      // step 2 : createSession
      await client.createSession({userName: "user_name", password: "password"}, async (err, session) => {
        if(err){
            console.log(err)
        }
        if(!err){
           // do something
        }
      }
    }

Above in the do something part I tried:

var nodeId = "nodeId";
var nodesToWrite = [{
                nodeId: nodeId,
                attributeId: AttributeIds.Value,
                value: /*new DataValue(*/{
                  value: {/* Variant */
                    dataType: 1,
                    value: false
                    }
                  }
                }];
session.write(nodesToWrite, (err, statusCodes) => {
    if(!err){
          console.log("success", statusCodes);
        } else {
          console.log(err, statusCodes)
        }
    }
); 

But since the nodeId doesn't exist so it will throw the error that it doesn't exist. I found a snippet example to add variables from the server-side, but is it possible to do it from the client's side as we want to add some variables based on the other variables which I am monitoring from the client's side.

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Please see the link https://reference.opcfoundation.org/Core/docs/Part4/5.7.2/

And check with SDK/Server vendor, whether they support NodeManagement Service Set or not.

If yes, you can find a method in the session context like session.addNodes()

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!