How to use the node-opcua.OPCUAClient.create function in node-opcua

To help you get started, we’ve selected a few node-opcua examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client_ts.ts View on Github external
securityPolicy,
        serverCertificate,

        defaultSecureTokenLifetime: 40000,

        endpoint_must_exist: false,

        connectionStrategy: {
            initialDelay: 2000,
            maxDelay: 10 * 1000,
            maxRetry: 10
        }
    };
    console.log("Options = ", options.securityMode.toString(), options.securityPolicy.toString());

    client = OPCUAClient.create(options);

    console.log(" reconnecting to ", chalk.cyan.bold(endpointUrl));
    await client.connect(endpointUrl);

    let userIdentity: any; // anonymous
    if (argv.userName && argv.password) {

        userIdentity = {
            password: argv.password,
            userName: argv.userName
        };

    }

    the_session = await client.createSession(userIdentity);
    client.on("connection_reestablished", () => {
github node-opcua / node-opcua / packages / playground / sample_for_post.ts View on Github external
async function main() {

    const client = OPCUAClient.create({

        endpoint_must_exist: false
    });

    client.on("backoff", (retry: number, delay: number) => {
        console.log(" cannot connect to endpoint retry = ", retry,
            " next attempt in ", delay / 1000, "seconds");
    });

    // put the endpoint to your OPCUA Server here
    const endpointUrl = "opc.tcp://localhost:48020";

    try {

        await client.connect(endpointUrl);
github node-opcua / node-opcua / documentation / sample_client_ts.ts View on Github external
} from "node-opcua";



const connectionStrategy = {
  initialDelay: 1000,
  maxRetry: 1
};
const options = {
  applicationName: "MyClient",
  connectionStrategy: connectionStrategy,
  securityMode: MessageSecurityMode.None,
  securityPolicy: SecurityPolicy.None,
  endpoint_must_exist: false
};
const client = OPCUAClient.create(options);
const endpointUrl = "opc.tcp://opcuademo.sterfive.com:26543";
async function main() {
  try {
    // step 1 : connect to
    await client.connect(endpointUrl);
    console.log("connected !");

    // step 2 : createSession
    const session = await client.createSession();
    console.log("session created !");

    // step 3 : browse
    const browseResult = await session.browse("RootFolder");
    
    console.log("references of RootFolder :");
    for (const reference of browseResult.references) {
github node-opcua / node-opcua / packages / playground / client_with_simple_subscription.js View on Github external
(async () => {

    try {


        const client = OPCUAClient.create({
            applicationName: "ClientBrowseNextDemo",
            connectionStrategy: { maxRetry: -1 },
            endpoint_must_exist: false,
            keepSessionAlive: true,
            requestedSessionTimeout: 60 * 1000,
//            securityMode: MessageSecurityMode.SignAndEncrypt,
//            securityPolicy: SecurityPolicy.Basic256,
            connectionStrategy: {
                maxRetry: -1,
                maxDelay: 500,
                initialDelay: 100,

            },

            requestedSessionTimeout: 10000,
            certificateFile: "./certificates/client_certificate.pem",
github node-opcua / node-opcua / packages / node-opcua-samples / bin / simple_client_ts.ts View on Github external
securityMode,
        securityPolicy,

        endpoint_must_exist: false,
        keepSessionAlive: true,

        connectionStrategy: {
            initialDelay: 2000,
            maxDelay: 10 * 1000,
            maxRetry: 10
        },

        discoveryUrl
    };

    client = OPCUAClient.create(optionsInitial);

    client.on("backoff", (retry: number, delay: number) => {
        console.log(chalk.bgWhite.yellow("backoff  attempt #"), retry, " retrying in ", delay / 1000.0, " seconds");
    });

    console.log(" connecting to ", chalk.cyan.bold(endpointUrl));
    console.log("    strategy", client.connectionStrategy);

    try {
        await client.connect(endpointUrl);
    } catch (err) {
        console.log(chalk.red(" Cannot connect to ") + endpointUrl);
        console.log(" Error = ", err.message);
        return;
    }
github node-opcua / node-opcua-htmlpanel / app.js View on Github external
(async () => {
    try {
        const client = OPCUAClient.create({
            endpoint_must_exist: false
        });
        client.on("backoff", (retry, delay) => {
            console.log("Retrying to connect to ", endpointUrl, " attempt ", retry);
        });
        console.log(" connecting to ", chalk.cyan(endpointUrl));
        await client.connect(endpointUrl);
        console.log(" connected to ", chalk.cyan(endpointUrl));

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

        const subscription = await session.createSubscription2({
            requestedPublishingInterval: 2000,
            requestedMaxKeepAliveCount: 20,
            requestedLifetimeCount: 6000,