node-opcua-client 2.155.0 → 2.157.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.
Files changed (36) hide show
  1. package/dist/client_base.js +2 -2
  2. package/dist/client_base.js.map +1 -1
  3. package/dist/client_session.d.ts +5 -5
  4. package/dist/client_session.js.map +1 -1
  5. package/dist/client_session_keepalive_manager.js +7 -2
  6. package/dist/client_session_keepalive_manager.js.map +1 -1
  7. package/dist/client_subscription.d.ts +2 -0
  8. package/dist/client_subscription.js +1 -1
  9. package/dist/client_subscription.js.map +1 -1
  10. package/dist/index.d.ts +21 -2
  11. package/dist/index.js +22 -3
  12. package/dist/index.js.map +1 -1
  13. package/dist/private/client_base_impl.js +61 -36
  14. package/dist/private/client_base_impl.js.map +1 -1
  15. package/dist/private/client_monitored_item_group_impl.js +4 -0
  16. package/dist/private/client_monitored_item_group_impl.js.map +1 -1
  17. package/dist/private/client_monitored_item_impl.js +11 -0
  18. package/dist/private/client_monitored_item_impl.js.map +1 -1
  19. package/dist/private/client_publish_engine.js +14 -2
  20. package/dist/private/client_publish_engine.js.map +1 -1
  21. package/dist/private/client_session_impl.js +73 -59
  22. package/dist/private/client_session_impl.js.map +1 -1
  23. package/dist/private/client_subscription_impl.js +15 -4
  24. package/dist/private/client_subscription_impl.js.map +1 -1
  25. package/dist/private/opcua_client_impl.js +100 -94
  26. package/dist/private/opcua_client_impl.js.map +1 -1
  27. package/dist/private/reconnection/client_reconnection.js +1 -2
  28. package/dist/private/reconnection/client_reconnection.js.map +1 -1
  29. package/package.json +45 -47
  30. package/source/client_session.ts +7 -5
  31. package/source/client_subscription.ts +3 -0
  32. package/source/index.ts +21 -3
  33. package/source/private/client_base_impl.ts +6 -3
  34. package/source/private/client_session_impl.ts +1 -2
  35. package/source/private/client_subscription_impl.ts +1 -1
  36. package/source/private/reconnection/client_reconnection.ts +1 -2
@@ -61,7 +61,9 @@ import {
61
61
  CallMethodResult,
62
62
  HistoryReadRequest,
63
63
  HistoryReadResponse,
64
- HistoryReadValueIdOptions
64
+ HistoryReadValueIdOptions,
65
+ ReadValueId,
66
+ ReadValueIdOptions
65
67
  } from "node-opcua-types";
66
68
 
67
69
  import { ExtraDataTypeManager } from "node-opcua-client-dynamic-extension-object";
@@ -197,19 +199,19 @@ export interface ClientSessionReadService extends IBasicSessionRead {
197
199
  /**
198
200
  * @deprecated use read() instead
199
201
  */
200
- readVariableValue(nodeId: NodeIdLike, callback: ResponseCallback<DataValue>): void;
202
+ readVariableValue(nodeId: NodeIdLike | ReadValueIdOptions, callback: ResponseCallback<DataValue>): void;
201
203
  /**
202
204
  * @deprecated use read() instead
203
205
  */
204
- readVariableValue(nodeId: NodeIdLike): Promise<DataValue>;
206
+ readVariableValue(nodeId: NodeIdLike | ReadValueIdOptions): Promise<DataValue>;
205
207
  /**
206
208
  * @deprecated use read() instead
207
209
  */
208
- readVariableValue(nodeIds: NodeIdLike[], callback: ResponseCallback<DataValue[]>): void;
210
+ readVariableValue(nodeIds: (NodeIdLike | ReadValueIdOptions)[], callback: ResponseCallback<DataValue[]>): void;
209
211
  /**
210
212
  * @deprecated use read() instead
211
213
  */
212
- readVariableValue(nodeIds: NodeIdLike[]): Promise<DataValue[]>;
214
+ readVariableValue(nodeIds: (NodeIdLike | ReadValueIdOptions)[]): Promise<DataValue[]>;
213
215
  }
214
216
 
215
217
  // write services
@@ -231,6 +231,9 @@ export interface ClientSubscription extends EventEmitter {
231
231
  linksToRemove: ClientMonitoredItemBase[] | null
232
232
  ): Promise<SetTriggeringResponse>;
233
233
 
234
+ setPublishingMode(publishing: boolean): Promise<StatusCode>;
235
+ setPublishingMode(publishing: boolean, callback: Callback<StatusCode>): void;
236
+
234
237
  terminate(): Promise<void>;
235
238
  terminate(callback: ErrorCallback): void;
236
239
  }
package/source/index.ts CHANGED
@@ -1,7 +1,25 @@
1
- /**
2
- * @module node-opcua-client
1
+ /*!
2
+ * The MIT License (MIT)
3
+ * Copyright (c) 2022-2025 Sterfive SAS - 833264583 RCS ORLEANS - France (https://www.sterfive.com)
4
+ * Copyright (c) 2014-2022 Etienne Rossignon
5
+ *
6
+ * Permission is hereby granted, free of charge, to any person obtaining a copy of
7
+ * this software and associated documentation files (the "Software"), to deal in
8
+ * the Software without restriction, including without limitation the rights to
9
+ * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
10
+ * the Software, and to permit persons to whom the Software is furnished to do so,
11
+ * subject to the following conditions:
12
+ *
13
+ * The above copyright notice and this permission notice shall be included in all
14
+ * copies or substantial portions of the Software.
15
+ *
16
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
18
+ * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
19
+ * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
20
+ * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21
+ * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
3
22
  */
4
-
5
23
  export * from "./client_base";
6
24
  export * from "./opcua_client";
7
25
  export * from "./client_session";
@@ -609,6 +609,7 @@ export class ClientBaseImpl extends OPCUASecureObject implements OPCUAClientBase
609
609
  err!.message.match("BadCertificateInvalid") ||
610
610
  err!.message.match(/socket has been disconnected by third party/)
611
611
  ) {
612
+ // it is possible also that hte server has shutdown innapropriately the connection
612
613
  warningLog(
613
614
  "the server certificate has changed, we need to retrieve server certificate again: ",
614
615
  err.message
@@ -1236,7 +1237,10 @@ export class ClientBaseImpl extends OPCUASecureObject implements OPCUAClientBase
1236
1237
  }
1237
1238
  if (this._internalState === "disconnected" || this._internalState === "disconnecting") {
1238
1239
  if (this._internalState === "disconnecting") {
1239
- warningLog("[NODE-OPCUA-W26] OPCUAClient#disconnect called while already disconnecting");
1240
+ warningLog("[NODE-OPCUA-W26] OPCUAClient#disconnect called while already disconnecting. clientName=", this.clientName);
1241
+ }
1242
+ if (!this._reconnectionIsCanceled && this.isReconnecting) {
1243
+ errorLog("Internal Error : _reconnectionIsCanceled should be true if isReconnecting is true");
1240
1244
  }
1241
1245
  return callback();
1242
1246
  }
@@ -1666,7 +1670,7 @@ export class ClientBaseImpl extends OPCUASecureObject implements OPCUAClientBase
1666
1670
 
1667
1671
  debugLog("Entering _repairConnection ", this._internalState);
1668
1672
  if (this.#insideRepairConnection) {
1669
- errorLog("_repairConnection already in progress internal state = ", this._internalState);
1673
+ errorLog("_repairConnection already in progress internal state = ", this._internalState, "clientName =", this.clientName);
1670
1674
  this.#shouldRepairAgain = true;
1671
1675
  return;
1672
1676
  }
@@ -1675,7 +1679,6 @@ export class ClientBaseImpl extends OPCUASecureObject implements OPCUAClientBase
1675
1679
  debugLog("recreating new secure channel ", this._internalState);
1676
1680
  this._recreate_secure_channel((err1?: Error) => {
1677
1681
  debugLog("secureChannel#on(close) => _recreate_secure_channel returns ", err1 ? err1.message : "OK");
1678
-
1679
1682
  if (err1) {
1680
1683
  debugLog("_recreate_secure_channel has failed: err = ", err1.message);
1681
1684
  this.emit("close", err1);
@@ -2,7 +2,6 @@
2
2
  * @module node-opcua-client-private
3
3
  */
4
4
  import { EventEmitter } from "events";
5
- import { callbackify } from "util";
6
5
  import chalk from "chalk";
7
6
  import { assert } from "node-opcua-assert";
8
7
  import { AggregateFunction } from "node-opcua-constants";
@@ -632,7 +631,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession, Re
632
631
  options.numValuesPerNode = options.numValuesPerNode || 0;
633
632
  options.returnBounds = options.returnBounds || options.returnBounds === undefined ? true : false;
634
633
  options.isReadModified = options.isReadModified || false;
635
- options.timestampsToReturn = options.timestampsToReturn || TimestampsToReturn.Both;
634
+ options.timestampsToReturn = options.timestampsToReturn ?? TimestampsToReturn.Both;
636
635
 
637
636
  const arg0 = args[0];
638
637
  const isArray = Array.isArray(arg0);
@@ -244,7 +244,7 @@ export class ClientSubscriptionImpl extends EventEmitter implements ClientSubscr
244
244
 
245
245
  if (this.subscriptionId === TERMINATED_SUBSCRIPTION_ID || this.subscriptionId === TERMINATING_SUBSCRIPTION_ID) {
246
246
  // already terminated... just ignore
247
- return callback(new Error("Already Terminated"));
247
+ return callback();
248
248
  }
249
249
 
250
250
  if (isFinite(this.subscriptionId)) {
@@ -1,4 +1,3 @@
1
- import { warn } from "console";
2
1
  import { ClientBaseImpl } from "../client_base_impl";
3
2
 
4
3
  export function waitUntilReconnectionIsCanceled(client: ClientBaseImpl, callback: () => void) {
@@ -9,7 +8,7 @@ export function waitUntilReconnectionIsCanceled(client: ClientBaseImpl, callback
9
8
  if (!client.isReconnecting || ++intervalCount > maxIntervalCount) {
10
9
  clearInterval(timer);
11
10
  if (intervalCount > maxIntervalCount) {
12
- warn("waitUntilReconnectionIsCanceled: timeout");
11
+ console.warn("waitUntilReconnectionIsCanceled: timeout");
13
12
  }
14
13
  callback();
15
14
  }