Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

116
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda