Registry / communication / node-opcua-client-proxy

node-opcua-client-proxy

JSON →
library2.169.0jsnpmunverified

The `node-opcua-client-proxy` package is a specialized module within the comprehensive `node-opcua` pure Node.js OPC UA SDK, currently at version 2.169.0. It provides functionalities for creating client-side proxies to interact with OPC UA servers, facilitating streamlined machine-to-machine (M2M) and Internet of Things (IoT) communication patterns. The `node-opcua` project maintains an active release cadence, with frequent updates focusing on stability, performance, and OPC UA specification compliance (e.g., full support for OPC UA 1.05 subtyped structures and unions). Recent releases have introduced features like advertised endpoints for Docker/NAT deployments and a global method-call interceptor API, alongside significant internal migrations from older libraries (`async`/`lodash`) to native modern JavaScript. Key differentiators include its robust TypeScript support, comprehensive certificate management capabilities, and continuous optimization for memory and throughput, particularly in its secure channel and transport layers. This specific module is designed to provide a structured and potentially higher-level abstraction for client interactions with the OPC UA address space, simplifying common operations.

npm install node-opcua-client-proxy
INSTALL
IMPORT
SIG · NODE-OPCUA-CLIENT-
N
node-opcua-client-proxy
communicationjavascriptv2.169.0
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

OPCUAClient
import { OPCUAClient } from 'node-opcua'
const OPCUAClient = require('node-opcua').OPCUAClient
The primary client entry point; typically imported from the main `node-opcua` package, as `node-opcua-client-proxy` usually builds upon it. ESM is the recommended import style.
ClientSession
import { ClientSession } from 'node-opcua'
import { ClientSession } from 'node-opcua-client-proxy'
Represents an active, authenticated session with an OPC UA server. Similar to `OPCUAClient`, it's usually imported from the core `node-opcua` package.
ClientProxy
import { ClientProxy } from 'node-opcua-client-proxy'
const { ClientProxy } = require('node-opcua-client-proxy')
The main class or interface provided by this specific `client-proxy` package, offering abstracted interaction with the OPC UA server via a session.
readVariableValue
import { readVariableValue } from 'node-opcua-client-proxy'
A representative example of a utility function or method potentially exposed by the `ClientProxy` for simplified reading of OPC UA variable values.

This quickstart demonstrates how to establish a connection to an OPC UA server, create a client session, and perform a basic read operation on a variable. It shows the setup of the `OPCUAClient`, session creation, and how `ClientProxy` might be instantiated, along with error handling and graceful disconnection. Remember to set `OPCUA_ENDPOINT_URL`, `OPCUA_USERNAME`, and `OPCUA_PASSWORD` environment variables.

import { OPCUAClient, MessageSecurityMode, SecurityPolicy, ClientSession, TimestampsToReturn, AttributeIds } from 'node-opcua'; import { ClientProxy } from 'node-opcua-client-proxy'; const endpointUrl = process.env.OPCUA_ENDPOINT_URL ?? 'opc.tcp://localhost:4840'; const userIdentity = { userName: process.env.OPCUA_USERNAME ?? 'user', password: process.env.OPCUA_PASSWORD ?? 'password' }; async function connectAndRead() { const client = OPCUAClient.create({ endpointUrl: endpointUrl, securityMode: MessageSecurityMode.None, // For demo purposes, consider stronger security in production securityPolicy: SecurityPolicy.None, // clientCertificateManager: provide a proper cert manager in production connectionStrategy: { maxRetry: 5, initialDelay: 500, maxDelay: 3000 } }); client.on('backoff', (retry, delay) => { console.log(`Connection attempt failed. Retrying in ${delay / 1000}s (attempt ${retry})`); }); let session: ClientSession | null = null; try { console.log(`Connecting to ${endpointUrl}...`); await client.connect(endpointUrl); console.log('Connected to OPC UA server.'); session = await client.createSession(userIdentity); console.log(`Session created with id: ${session.sessionId.toString()}`); // Instantiate the ClientProxy with the established session const proxy = new ClientProxy(session); // Example: Reading a specific node's value via the proxy (assuming proxy has a 'read' method) const nodeIdToRead = 'ns=2;s=MyDevice/Temperature'; // Replace with a valid NodeId from your server console.log(`Attempting to read NodeId: ${nodeIdToRead}`); // Using session.read directly for now as proxy API is inferred const dataValue = await session.read({ nodeId: nodeIdToRead, attributeId: AttributeIds.Value, timestampsToReturn: TimestampsToReturn.Both }); if (dataValue.statusCode.isGood()) { console.log(`Value of ${nodeIdToRead}: ${dataValue.value?.value} (Source Timestamp: ${dataValue.sourceTimestamp?.toISOString()})`); } else { console.error(`Failed to read ${nodeIdToRead}: ${dataValue.statusCode.toString()}`); } } catch (err) { console.error('An error occurred during OPC UA communication:', err); } finally { if (session) { await session.close(); console.log('Session closed.'); } if (client) { await client.disconnect(); console.log('Disconnected from OPC UA server.'); } } } connectAndRead();
Debug
Known issues
breakingCore packages in `node-opcua` have undergone a significant migration from relying on external libraries like `async` and `lodash` to utilizing native modern JavaScript patterns. While `node-opcua-client-proxy` primarily exposes a higher-level API, direct reliance on or interaction with any underlying `async`/`lodash` utilities (e.g., for internal data structures or callbacks) might require code adjustments.
fix
Review any custom client implementations or extensions that might have implicitly relied on `async`/`lodash` internals. Refactor code to use standard ES features (e.g., `Promise`, `Array.prototype` methods). Ensure no internal typings from these deprecated libraries are still being used.
affects: >=2.168.0
gotchaThe certificate management architecture has been extensively refactored, particularly for server-side components like `PushCertificateManagerServerImpl` and `OPCUACertificateManager`. While `node-opcua-client-proxy` is client-focused, clients interacting with servers using the updated certificate handling, especially via GDS push models or requiring full certificate chain trust, should verify their trust list configuration.
fix
Ensure client-side certificate trust list management is up-to-date and correctly configured to process certificate chains. Consult the `node-opcua-pki` documentation for the latest certificate management APIs if building custom certificate handling solutions. Always test certificate-based connections thoroughly after upgrading.
affects: >=2.164.2
gotchaSignificant performance and memory optimizations have been applied to core transport, secure channel, and chunk manager layers. While these generally improve efficiency, custom low-level client configurations, or those relying on specific memory usage profiles or timing characteristics of older versions, might experience subtle behavioral changes or require re-tuning.
fix
Monitor resource usage (CPU, memory) and connection/data throughput in production environments after upgrading. Review any custom transport layer parameters, buffer management, or memory allocation strategies if unexpected behavior or resource issues arise.
affects: >=2.162.0
breakingA bug fix in `v2.161.0` ensures that `historyRead` results correctly promote `OpaqueStructure` to `ExtensionObject` within `HistoryData`. If previous client logic had workarounds or incorrectly parsed `OpaqueStructure` from `historyRead` results, it will now receive the corrected `ExtensionObject` types, which could break existing data parsing.
fix
Clients consuming `historyRead` results, especially for complex data types or those containing `ExtensionObject`s, must verify their data parsing logic to correctly handle the now-promoted `ExtensionObject` structures. Update any casting or type-checking logic as necessary.
affects: >=2.161.0
Errors
Common errors & fixes
Error: self-signed certificate in certificate chain
The OPC UA client is attempting to establish a secure connection with a server that presents a self-signed certificate, which is not implicitly trusted by the client's certificate store.
fix
To resolve this, you must configure the client's `clientCertificateManager` to explicitly trust the server's certificate. For development, you might temporarily set security mode to `None`, but this is not recommended for production environments.
Error: The provided endpoint is not supported
The client attempted to connect to an endpoint URL with a security mode, security policy, or transport protocol that the target OPC UA server does not advertise or support. This can also indicate an incorrect endpoint URL format.
fix
Verify that the `endpointUrl` is exact and corresponds to one advertised by the server. Use `OPCUAClient.getEndpoints()` to programmatically inspect available server endpoints and ensure your client's security settings (mode, policy) match a supported configuration.
TypeError: OPCUAClient is not a constructor
This error typically occurs when attempting to use CommonJS `require` syntax (`const { OPCUAClient} = require('node-opcua')`) with an ESM-only package or when mixing module systems incorrectly. The `node-opcua` library ecosystem primarily uses ES Modules.
fix
Ensure you are using ES Module `import` syntax (`import { OPCUAClient } from 'node-opcua';`) and that your Node.js project is configured to run ES Modules (e.g., by adding `"type": "module"` to your `package.json` or using `.mjs` file extensions).
Upgrade
Version history
2.169.0latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
11 hits · last 30 days
node
10
OpenAI (training)
1
Resources
node-opcua-client-proxy — npm install node-opcua-client-proxy · libregistry