node-opcua-client 2.173.1 → 2.174.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +67 -33
- package/dist/client_session.d.ts +75 -3
- package/dist/opcua_client.d.ts +139 -5
- package/dist/opcua_client.js +40 -0
- package/dist/opcua_client.js.map +1 -1
- package/dist/private/client_session_impl.d.ts +1 -0
- package/dist/private/client_session_impl.js +1 -0
- package/dist/private/client_session_impl.js.map +1 -1
- package/dist/private/opcua_client_impl.js +6 -2
- package/dist/private/opcua_client_impl.js.map +1 -1
- package/dist/private/reconnection/client_publish_engine_reconnection.js +41 -7
- package/dist/private/reconnection/client_publish_engine_reconnection.js.map +1 -1
- package/dist/private/reconnection/reconnection.js +12 -0
- package/dist/private/reconnection/reconnection.js.map +1 -1
- package/package.json +38 -38
- package/source/client_session.ts +75 -3
- package/source/opcua_client.ts +139 -6
- package/source/private/client_session_impl.ts +15 -15
- package/source/private/opcua_client_impl.ts +19 -18
- package/source/private/reconnection/client_publish_engine_reconnection.ts +43 -8
- package/source/private/reconnection/reconnection.ts +13 -0
package/README.md
CHANGED
|
@@ -1,54 +1,88 @@
|
|
|
1
1
|
# node-opcua-client
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
[](https://www.npmjs.com/package/node-opcua-client)
|
|
4
|
+
[](https://www.npmjs.com/package/node-opcua-client)
|
|
5
|
+
[](https://github.com/node-opcua/node-opcua/actions/workflows/workflow.yml)
|
|
4
6
|
|
|
5
|
-
|
|
7
|
+
**Lightweight OPC UA client for Node.js** — connect to any OPC UA server, browse, read, write, and subscribe to data changes.
|
|
6
8
|
|
|
7
|
-
|
|
9
|
+
Part of the [node-opcua](https://github.com/node-opcua/node-opcua) project — the most popular OPC UA stack for Node.js.
|
|
8
10
|
|
|
9
|
-
|
|
11
|
+
## When to use this package
|
|
10
12
|
|
|
11
|
-
|
|
13
|
+
| Package | Use case |
|
|
14
|
+
|---|---|
|
|
15
|
+
| **`node-opcua-client`** | You only need **client** capabilities (smaller install, faster startup) |
|
|
16
|
+
| **`node-opcua`** | You need **both** client and server in the same project |
|
|
12
17
|
|
|
13
|
-
##
|
|
18
|
+
## Quick Start
|
|
14
19
|
|
|
15
|
-
|
|
20
|
+
```bash
|
|
21
|
+
npm install node-opcua-client
|
|
22
|
+
```
|
|
16
23
|
|
|
17
|
-
|
|
18
|
-
- https://opencollective.com/node-opcua
|
|
24
|
+
> **Requires Node.js 20 or later.**
|
|
19
25
|
|
|
20
|
-
|
|
26
|
+
### Connect, read, and disconnect
|
|
21
27
|
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
+
```typescript
|
|
29
|
+
import {
|
|
30
|
+
OPCUAClient,
|
|
31
|
+
AttributeIds,
|
|
32
|
+
DataValue,
|
|
33
|
+
} from "node-opcua-client";
|
|
28
34
|
|
|
29
|
-
|
|
35
|
+
(async () => {
|
|
36
|
+
// 1. Create a client and connect to an OPC UA server
|
|
37
|
+
const client = OPCUAClient.create({ endpointMustExist: false });
|
|
38
|
+
await client.connect("opc.tcp://opcuademo.sterfive.com:26543");
|
|
30
39
|
|
|
31
|
-
|
|
40
|
+
// 2. Create a session
|
|
41
|
+
const session = await client.createSession();
|
|
32
42
|
|
|
33
|
-
|
|
43
|
+
// 3. Read the server's current time (ns=0;i=2258)
|
|
44
|
+
const dataValue: DataValue = await session.read({
|
|
45
|
+
nodeId: "ns=0;i=2258",
|
|
46
|
+
attributeId: AttributeIds.Value,
|
|
47
|
+
});
|
|
48
|
+
console.log("Server time:", dataValue.value.value);
|
|
34
49
|
|
|
35
|
-
|
|
50
|
+
// 4. Clean up
|
|
51
|
+
await session.close();
|
|
52
|
+
await client.disconnect();
|
|
53
|
+
})();
|
|
54
|
+
```
|
|
36
55
|
|
|
37
|
-
|
|
56
|
+
## 📖 Documentation
|
|
38
57
|
|
|
39
|
-
|
|
58
|
+
- 📘 [**NodeOPCUA by Example**](https://leanpub.com/node-opcuabyexample-edition2024) — The best starting point: practical, ready-to-use examples with full explanations.
|
|
59
|
+
- 📚 [**API Reference**](https://node-opcua.github.io/api_doc/index.html) — Complete API documentation.
|
|
60
|
+
- 🛠️ [**Client Tutorial**](https://github.com/node-opcua/node-opcua/blob/master/documentation/creating_a_client_typescript.md) — Step-by-step guide to building an OPC UA client in TypeScript.
|
|
40
61
|
|
|
41
|
-
|
|
62
|
+
## 🏢 Professional Support
|
|
42
63
|
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
64
|
+
| Feature | Community (GitHub) | Professional ([Sterfive](https://support.sterfive.com)) |
|
|
65
|
+
|---|:---:|:---:|
|
|
66
|
+
| Bug reports via GitHub Issues | ✅ | ✅ |
|
|
67
|
+
| CVE security advisories | After disclosure | **Early access — patch before public disclosure** |
|
|
68
|
+
| Priority response time | — | ✅ |
|
|
69
|
+
| Private support channel | — | ✅ |
|
|
70
|
+
| Architecture & code review | — | ✅ |
|
|
71
|
+
| Dedicated consulting hours | — | ✅ |
|
|
72
|
+
| Certifiable version | — | ✅ |
|
|
50
73
|
|
|
51
|
-
|
|
74
|
+
[](https://support.sterfive.com)
|
|
52
75
|
|
|
53
|
-
|
|
54
|
-
|
|
76
|
+
📧 Contact: [contact@sterfive.com](mailto:contact@sterfive.com)
|
|
77
|
+
|
|
78
|
+
## :heart: Sponsors
|
|
79
|
+
|
|
80
|
+
If you find this package valuable, please consider supporting the project:
|
|
81
|
+
|
|
82
|
+
- [**Become a sponsor on GitHub**](https://github.com/sponsors/node-opcua)
|
|
83
|
+
|
|
84
|
+
Your sponsorship ensures long-term maintenance, new features, and continued OPC Foundation representation.
|
|
85
|
+
|
|
86
|
+
## License
|
|
87
|
+
|
|
88
|
+
MIT — Copyright © 2014-2026 [Etienne Rossignon](https://github.com/erossignon) / [Sterfive SAS](https://www.sterfive.com)
|
package/dist/client_session.d.ts
CHANGED
|
@@ -69,10 +69,58 @@ export interface ClientSessionBase {
|
|
|
69
69
|
* the session name
|
|
70
70
|
*/
|
|
71
71
|
name: string;
|
|
72
|
+
/**
|
|
73
|
+
* the StatusCode returned by the last ActivateSession — usually `Good`, but
|
|
74
|
+
* e.g. `Good_PasswordChangeRequired` when the user must change the password
|
|
75
|
+
* (OPC 10000-18 §5.2.8). Lets a Client react without server-side access.
|
|
76
|
+
*/
|
|
77
|
+
lastActivateSessionStatusCode: StatusCode;
|
|
78
|
+
/**
|
|
79
|
+
* Close the session.
|
|
80
|
+
*
|
|
81
|
+
* @param deleteSubscription - if `true` (the default), all
|
|
82
|
+
* subscriptions created on this session are deleted on
|
|
83
|
+
* the server. Set to `false` to preserve subscriptions
|
|
84
|
+
* for later transfer to a new session.
|
|
85
|
+
*/
|
|
72
86
|
close(callback: ErrorCallback): void;
|
|
73
87
|
close(deleteSubscription: boolean, callback: ErrorCallback): void;
|
|
74
88
|
close(deleteSubscription?: boolean): Promise<void>;
|
|
75
89
|
}
|
|
90
|
+
/**
|
|
91
|
+
* An active session to an OPC UA server.
|
|
92
|
+
*
|
|
93
|
+
* `ClientSession` provides access to all OPC UA services:
|
|
94
|
+
* reading and writing node values, browsing the address space,
|
|
95
|
+
* calling methods, and creating subscriptions for data change
|
|
96
|
+
* or event notifications.
|
|
97
|
+
*
|
|
98
|
+
* Sessions are created via {@link OPCUAClient.createSession} or
|
|
99
|
+
* {@link OPCUAClient.create} followed by `client.createSession()`.
|
|
100
|
+
*
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* const session = await client.createSession();
|
|
104
|
+
*
|
|
105
|
+
* // Read a value
|
|
106
|
+
* const dataValue = await session.read({
|
|
107
|
+
* nodeId: "ns=0;i=2258",
|
|
108
|
+
* attributeId: AttributeIds.Value,
|
|
109
|
+
* });
|
|
110
|
+
*
|
|
111
|
+
* // Browse the root folder
|
|
112
|
+
* const browseResult = await session.browse("RootFolder");
|
|
113
|
+
*
|
|
114
|
+
* // Write a value
|
|
115
|
+
* await session.write({
|
|
116
|
+
* nodeId: "ns=1;s=MyVariable",
|
|
117
|
+
* attributeId: AttributeIds.Value,
|
|
118
|
+
* value: { value: { dataType: DataType.Double, value: 42.0 } },
|
|
119
|
+
* });
|
|
120
|
+
*
|
|
121
|
+
* await session.close();
|
|
122
|
+
* ```
|
|
123
|
+
*/
|
|
76
124
|
export interface ClientSession extends ClientSessionBase {
|
|
77
125
|
serverEndpoints: EndpointDescription[];
|
|
78
126
|
}
|
|
@@ -87,11 +135,17 @@ export interface ClientSession extends EventEmitter {
|
|
|
87
135
|
on(event: "session_restored", eventHandler: () => void): this;
|
|
88
136
|
on(event: string | symbol, listener: (...args: any[]) => void): this;
|
|
89
137
|
}
|
|
138
|
+
/**
|
|
139
|
+
* Browse service — navigate the OPC UA address space.
|
|
140
|
+
*
|
|
141
|
+
* The `browse()` and `browseNext()` methods are inherited from
|
|
142
|
+
* {@link node-opcua-pseudo-session!IBasicSessionBrowse}.
|
|
143
|
+
*/
|
|
90
144
|
export interface ClientSessionBrowseService extends IBasicSessionBrowse, IBasicSessionBrowseNext {
|
|
91
145
|
/**
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
* with browseNext
|
|
146
|
+
* The maximum number of references the server should return
|
|
147
|
+
* per browse result. If the server has more, it returns a
|
|
148
|
+
* continuation point to retrieve the rest with `browseNext()`.
|
|
95
149
|
*/
|
|
96
150
|
requestedMaxReferencesPerNode: number;
|
|
97
151
|
}
|
|
@@ -101,7 +155,19 @@ export interface ClientSessionQueryService {
|
|
|
101
155
|
queryFirst(queryFirstRequest: QueryFirstRequestLike): Promise<QueryFirstResponse>;
|
|
102
156
|
queryFirst(queryFirstRequest: QueryFirstRequestLike, callback: ResponseCallback<QueryFirstResponse>): void;
|
|
103
157
|
}
|
|
158
|
+
/**
|
|
159
|
+
* Call service — invoke methods on server objects.
|
|
160
|
+
*
|
|
161
|
+
* The `call()` method is inherited from
|
|
162
|
+
* {@link node-opcua-pseudo-session!IBasicSessionCall}.
|
|
163
|
+
*/
|
|
104
164
|
export interface ClientSessionCallService extends IBasicSessionCall {
|
|
165
|
+
/**
|
|
166
|
+
* Retrieve the input and output argument definitions of a method.
|
|
167
|
+
*
|
|
168
|
+
* @param methodId - the NodeId of the method
|
|
169
|
+
* @returns the argument definitions (input and output)
|
|
170
|
+
*/
|
|
105
171
|
getArgumentDefinition(methodId: MethodId): Promise<ArgumentDefinition>;
|
|
106
172
|
getArgumentDefinition(methodId: MethodId, callback: (err: Error | null, args?: ArgumentDefinition) => void): void;
|
|
107
173
|
}
|
|
@@ -139,6 +205,12 @@ export interface ClientSessionWriteService extends IBasicSessionWrite {
|
|
|
139
205
|
*/
|
|
140
206
|
writeSingleNode(nodeToWrite: NodeIdLike, value: Variant, callback: ResponseCallback<StatusCode>): void;
|
|
141
207
|
}
|
|
208
|
+
/**
|
|
209
|
+
* Raw subscription service — low-level OPC UA subscription management.
|
|
210
|
+
*
|
|
211
|
+
* For a higher-level API, use {@link ClientSubscription} via
|
|
212
|
+
* `ClientSession.createSubscription2()`.
|
|
213
|
+
*/
|
|
142
214
|
export interface ClientSessionRawSubscriptionService {
|
|
143
215
|
/**
|
|
144
216
|
*
|
package/dist/opcua_client.d.ts
CHANGED
|
@@ -48,47 +48,181 @@ export type WithSessionFunc = (session: ClientSession) => Promise<void>;
|
|
|
48
48
|
export type WithSessionFuncP<T> = (session: ClientSession) => Promise<T>;
|
|
49
49
|
export type WithSubscriptionFunc = (session: ClientSession, subscription: ClientSubscription) => Promise<void>;
|
|
50
50
|
export type WithSubscriptionFuncP<T> = (session: ClientSession, subscription: ClientSubscription) => Promise<T>;
|
|
51
|
+
/**
|
|
52
|
+
* The OPC UA client interface.
|
|
53
|
+
*
|
|
54
|
+
* `OPCUAClient` provides methods to connect to an OPC UA server,
|
|
55
|
+
* create sessions, and manage the client lifecycle.
|
|
56
|
+
*
|
|
57
|
+
* Use {@link OPCUAClient.create} to instantiate a client.
|
|
58
|
+
*
|
|
59
|
+
* @example
|
|
60
|
+
* ```typescript
|
|
61
|
+
* const client = OPCUAClient.create({ endpointMustExist: false });
|
|
62
|
+
* await client.connect("opc.tcp://localhost:26543");
|
|
63
|
+
* const session = await client.createSession();
|
|
64
|
+
* // ... use the session ...
|
|
65
|
+
* await session.close();
|
|
66
|
+
* await client.disconnect();
|
|
67
|
+
* ```
|
|
68
|
+
*/
|
|
51
69
|
export interface OPCUAClient<Events extends OPCUAClientBaseEvents = OPCUAClientBaseEvents> extends OPCUAClientBase<Events> {
|
|
70
|
+
/**
|
|
71
|
+
* Connect the client to the specified OPC UA server endpoint.
|
|
72
|
+
*
|
|
73
|
+
* The client will establish a secure channel, negotiate security
|
|
74
|
+
* parameters, and verify the server certificate.
|
|
75
|
+
*
|
|
76
|
+
* @param endpointUrl - the OPC UA endpoint URL (e.g. `"opc.tcp://host:4840"`)
|
|
77
|
+
*/
|
|
52
78
|
connect(endpointUrl: string): Promise<void>;
|
|
53
79
|
connect(endpointUrl: string, callback: ErrorCallback): void;
|
|
80
|
+
/**
|
|
81
|
+
* Disconnect the client from the server.
|
|
82
|
+
*
|
|
83
|
+
* This closes all active sessions, subscriptions, and the
|
|
84
|
+
* underlying secure channel.
|
|
85
|
+
*/
|
|
54
86
|
disconnect(): Promise<void>;
|
|
55
87
|
disconnect(callback: ErrorCallback): void;
|
|
88
|
+
/**
|
|
89
|
+
* Retrieve the list of endpoints exposed by the server.
|
|
90
|
+
*
|
|
91
|
+
* @param options - optional filter criteria for the endpoint query
|
|
92
|
+
* @returns the array of endpoint descriptions advertised by the server
|
|
93
|
+
*/
|
|
56
94
|
getEndpoints(options?: GetEndpointsOptions): Promise<EndpointDescription[]>;
|
|
57
95
|
getEndpoints(options: GetEndpointsOptions, callback: ResponseCallback<EndpointDescription[]>): void;
|
|
58
96
|
getEndpoints(callback: ResponseCallback<EndpointDescription[]>): void;
|
|
97
|
+
/**
|
|
98
|
+
* Discover OPC UA servers registered on the network.
|
|
99
|
+
*
|
|
100
|
+
* @param options - optional filter criteria for the discovery query
|
|
101
|
+
* @returns the array of discovered server application descriptions
|
|
102
|
+
*/
|
|
59
103
|
findServers(options?: FindServersRequestLike): Promise<ApplicationDescription[]>;
|
|
60
104
|
findServers(options: FindServersRequestLike, callback: ResponseCallback<ApplicationDescription[]>): void;
|
|
61
105
|
findServers(callback: ResponseCallback<ApplicationDescription[]>): void;
|
|
106
|
+
/**
|
|
107
|
+
* Create a new session on the connected server.
|
|
108
|
+
*
|
|
109
|
+
* If `userIdentityInfo` is not provided, an anonymous session
|
|
110
|
+
* is created.
|
|
111
|
+
*
|
|
112
|
+
* @param userIdentityInfo - optional credentials for user authentication
|
|
113
|
+
* @returns the newly created client session
|
|
114
|
+
*/
|
|
62
115
|
createSession(userIdentityInfo?: UserIdentityInfo): Promise<ClientSession>;
|
|
63
116
|
createSession(userIdentityInfo: UserIdentityInfo, callback: (err: Error | null, session?: ClientSession) => void): void;
|
|
64
117
|
createSession(callback: (err: Error | null, session?: ClientSession) => void): void;
|
|
118
|
+
/**
|
|
119
|
+
* Create a new session, using createSession2 service (OPC UA 1.04+).
|
|
120
|
+
*
|
|
121
|
+
* @param userIdentityInfo - optional credentials for user authentication
|
|
122
|
+
* @returns the newly created client session
|
|
123
|
+
*/
|
|
65
124
|
createSession2(userIdentityInfo?: UserIdentityInfo): Promise<ClientSession>;
|
|
66
125
|
createSession2(userIdentityInfo: UserIdentityInfo, callback: (err: Error | null, session?: ClientSession) => void): void;
|
|
67
126
|
createSession2(callback: (err: Error | null, session?: ClientSession) => void): void;
|
|
68
127
|
/** @deprecated */
|
|
69
128
|
changeSessionIdentity(session: ClientSession, userIdentityInfo: UserIdentityInfo): Promise<StatusCode>;
|
|
70
129
|
changeSessionIdentity(session: ClientSession, userIdentityInfo: UserIdentityInfo, callback: CallbackT<StatusCode>): void;
|
|
130
|
+
/**
|
|
131
|
+
* Close a previously created session.
|
|
132
|
+
*
|
|
133
|
+
* @param session - the session to close
|
|
134
|
+
* @param deleteSubscriptions - if `true`, all subscriptions
|
|
135
|
+
* associated with the session are deleted on the server
|
|
136
|
+
*/
|
|
71
137
|
closeSession(session: ClientSession, deleteSubscriptions: boolean): Promise<void>;
|
|
72
138
|
closeSession(session: ClientSession, deleteSubscriptions: boolean, callback: (err?: Error) => void): void;
|
|
139
|
+
/**
|
|
140
|
+
* Reactivate a session that was previously transferred or
|
|
141
|
+
* disconnected.
|
|
142
|
+
*
|
|
143
|
+
* @param session - the session to reactivate
|
|
144
|
+
*/
|
|
73
145
|
reactivateSession(session: ClientSession): Promise<void>;
|
|
74
146
|
reactivateSession(session: ClientSession, callback: (err?: Error) => void): void;
|
|
147
|
+
/** @internal */
|
|
75
148
|
createDefaultCertificate(): Promise<void>;
|
|
76
149
|
/**
|
|
150
|
+
* Connect to a server, execute an async function within a session,
|
|
151
|
+
* then automatically close the session and disconnect.
|
|
152
|
+
*
|
|
153
|
+
* This is a convenience method for simple one-shot operations.
|
|
154
|
+
*
|
|
155
|
+
* @param endpointUrl - the server endpoint URL or endpoint with credentials
|
|
156
|
+
* @param inner_func - the async function to execute with the session
|
|
157
|
+
* @returns the value returned by `inner_func`
|
|
77
158
|
*
|
|
78
|
-
* @
|
|
79
|
-
*
|
|
159
|
+
* @example
|
|
160
|
+
* ```typescript
|
|
161
|
+
* const result = await client.withSessionAsync(
|
|
162
|
+
* "opc.tcp://localhost:26543",
|
|
163
|
+
* async (session) => {
|
|
164
|
+
* return await session.read({ nodeId: "ns=0;i=2258",
|
|
165
|
+
* attributeId: AttributeIds.Value });
|
|
166
|
+
* }
|
|
167
|
+
* );
|
|
168
|
+
* ```
|
|
80
169
|
*/
|
|
81
170
|
withSessionAsync<T>(endpointUrl: string | EndpointWithUserIdentity, inner_func: WithSessionFuncP<T>): Promise<T>;
|
|
82
171
|
/**
|
|
172
|
+
* Connect to a server, create a session and a subscription,
|
|
173
|
+
* execute an async function, then clean up everything.
|
|
83
174
|
*
|
|
84
|
-
*
|
|
85
|
-
*
|
|
86
|
-
* @param
|
|
175
|
+
* This is a convenience method for subscription-based operations.
|
|
176
|
+
*
|
|
177
|
+
* @param endpointUrl - the server endpoint URL or endpoint with credentials
|
|
178
|
+
* @param parameters - subscription creation parameters
|
|
179
|
+
* @param inner_func - the async function to execute with the session and subscription
|
|
180
|
+
* @returns the value returned by `inner_func`
|
|
87
181
|
*/
|
|
88
182
|
withSubscriptionAsync<T>(endpointUrl: string | EndpointWithUserIdentity, parameters: ClientSubscriptionOptions, inner_func: WithSubscriptionFuncP<T>): Promise<T>;
|
|
89
183
|
}
|
|
184
|
+
/**
|
|
185
|
+
* Factory class for creating OPC UA client instances.
|
|
186
|
+
*
|
|
187
|
+
* @example
|
|
188
|
+
* ```typescript
|
|
189
|
+
* import { OPCUAClient } from "node-opcua-client";
|
|
190
|
+
*
|
|
191
|
+
* const client = OPCUAClient.create({
|
|
192
|
+
* endpointMustExist: false,
|
|
193
|
+
* requestedSessionTimeout: 60000,
|
|
194
|
+
* });
|
|
195
|
+
* ```
|
|
196
|
+
*/
|
|
90
197
|
export declare class OPCUAClient {
|
|
198
|
+
/**
|
|
199
|
+
* Create a new OPC UA client instance.
|
|
200
|
+
*
|
|
201
|
+
* @param options - client configuration options
|
|
202
|
+
* @returns a configured OPC UA client ready to connect
|
|
203
|
+
*/
|
|
91
204
|
static create(options: OPCUAClientOptions): OPCUAClient;
|
|
205
|
+
/**
|
|
206
|
+
* Convenience method to create a client, connect, and establish
|
|
207
|
+
* a session in one call.
|
|
208
|
+
*
|
|
209
|
+
* @param endpointUrl - the OPC UA endpoint URL
|
|
210
|
+
* @param userIdentity - optional user credentials
|
|
211
|
+
* @param clientOptions - optional client configuration
|
|
212
|
+
* @returns a connected client session
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* ```typescript
|
|
216
|
+
* const session = await OPCUAClient.createSession(
|
|
217
|
+
* "opc.tcp://localhost:26543"
|
|
218
|
+
* );
|
|
219
|
+
* const dataValue = await session.read({
|
|
220
|
+
* nodeId: "ns=0;i=2258",
|
|
221
|
+
* attributeId: AttributeIds.Value,
|
|
222
|
+
* });
|
|
223
|
+
* await session.close(true); // deleteSubscriptions = true
|
|
224
|
+
* ```
|
|
225
|
+
*/
|
|
92
226
|
static createSession(endpointUrl: string, userIdentity?: UserIdentityInfo, clientOptions?: OPCUAClientOptions): Promise<ClientSession>;
|
|
93
227
|
static set minimumRevisedSessionTimeout(minimumRevisedSessionTimeout: number);
|
|
94
228
|
static get minimumRevisedSessionTimeout(): number;
|
package/dist/opcua_client.js
CHANGED
|
@@ -5,10 +5,50 @@
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
6
|
exports.OPCUAClient = void 0;
|
|
7
7
|
const opcua_client_impl_1 = require("./private/opcua_client_impl");
|
|
8
|
+
/**
|
|
9
|
+
* Factory class for creating OPC UA client instances.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { OPCUAClient } from "node-opcua-client";
|
|
14
|
+
*
|
|
15
|
+
* const client = OPCUAClient.create({
|
|
16
|
+
* endpointMustExist: false,
|
|
17
|
+
* requestedSessionTimeout: 60000,
|
|
18
|
+
* });
|
|
19
|
+
* ```
|
|
20
|
+
*/
|
|
8
21
|
class OPCUAClient {
|
|
22
|
+
/**
|
|
23
|
+
* Create a new OPC UA client instance.
|
|
24
|
+
*
|
|
25
|
+
* @param options - client configuration options
|
|
26
|
+
* @returns a configured OPC UA client ready to connect
|
|
27
|
+
*/
|
|
9
28
|
static create(options) {
|
|
10
29
|
return new opcua_client_impl_1.OPCUAClientImpl(options);
|
|
11
30
|
}
|
|
31
|
+
/**
|
|
32
|
+
* Convenience method to create a client, connect, and establish
|
|
33
|
+
* a session in one call.
|
|
34
|
+
*
|
|
35
|
+
* @param endpointUrl - the OPC UA endpoint URL
|
|
36
|
+
* @param userIdentity - optional user credentials
|
|
37
|
+
* @param clientOptions - optional client configuration
|
|
38
|
+
* @returns a connected client session
|
|
39
|
+
*
|
|
40
|
+
* @example
|
|
41
|
+
* ```typescript
|
|
42
|
+
* const session = await OPCUAClient.createSession(
|
|
43
|
+
* "opc.tcp://localhost:26543"
|
|
44
|
+
* );
|
|
45
|
+
* const dataValue = await session.read({
|
|
46
|
+
* nodeId: "ns=0;i=2258",
|
|
47
|
+
* attributeId: AttributeIds.Value,
|
|
48
|
+
* });
|
|
49
|
+
* await session.close(true); // deleteSubscriptions = true
|
|
50
|
+
* ```
|
|
51
|
+
*/
|
|
12
52
|
static async createSession(endpointUrl, userIdentity, clientOptions) {
|
|
13
53
|
return opcua_client_impl_1.OPCUAClientImpl.createSession(endpointUrl, userIdentity, clientOptions);
|
|
14
54
|
}
|
package/dist/opcua_client.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opcua_client.js","sourceRoot":"","sources":["../source/opcua_client.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAeH,mEAA8D;
|
|
1
|
+
{"version":3,"file":"opcua_client.js","sourceRoot":"","sources":["../source/opcua_client.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAeH,mEAA8D;AA6M9D;;;;;;;;;;;;GAYG;AACH,MAAa,WAAW;IACpB;;;;;OAKG;IACI,MAAM,CAAC,MAAM,CAAC,OAA2B;QAC5C,OAAO,IAAI,mCAAe,CAAC,OAAO,CAA2B,CAAC;IAClE,CAAC;IACD;;;;;;;;;;;;;;;;;;;;OAoBG;IACI,MAAM,CAAC,KAAK,CAAC,aAAa,CAC7B,WAAmB,EACnB,YAA+B,EAC/B,aAAkC;QAElC,OAAO,mCAAe,CAAC,aAAa,CAAC,WAAW,EAAE,YAAY,EAAE,aAAa,CAAC,CAAC;IACnF,CAAC;IACM,MAAM,KAAK,4BAA4B,CAAC,4BAAoC;QAC/E,mCAAe,CAAC,4BAA4B,GAAG,4BAA4B,CAAC;IAChF,CAAC;IACM,MAAM,KAAK,4BAA4B;QAC1C,OAAO,mCAAe,CAAC,4BAA4B,CAAC;IACxD,CAAC;CACJ;AA5CD,kCA4CC"}
|
|
@@ -59,6 +59,7 @@ export declare class ClientSessionImpl extends EventEmitter implements ClientSes
|
|
|
59
59
|
serverNonce?: Nonce;
|
|
60
60
|
serverSignature?: SignatureData;
|
|
61
61
|
serverEndpoints: EndpointDescription[];
|
|
62
|
+
lastActivateSessionStatusCode: StatusCode;
|
|
62
63
|
_client: IClientBase | null;
|
|
63
64
|
_closed: boolean;
|
|
64
65
|
_reconnecting: {
|