node-opcua-client 2.112.0 → 2.113.1
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/dist/alarms_and_conditions/client_alarm_tools_acknowledge_all_conditions.js +2 -0
- package/dist/alarms_and_conditions/client_alarm_tools_acknowledge_all_conditions.js.map +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/private/client_base_impl.js +7 -2
- package/dist/private/client_base_impl.js.map +1 -1
- package/dist/private/client_publish_engine.js +3 -0
- package/dist/private/client_publish_engine.js.map +1 -1
- package/dist/private/client_session_impl.js +1 -1
- package/dist/private/client_session_impl.js.map +1 -1
- package/dist/private/client_subscription_impl.js +1 -0
- package/dist/private/client_subscription_impl.js.map +1 -1
- package/dist/reconnection.js +10 -3
- package/dist/reconnection.js.map +1 -1
- package/package.json +37 -37
- package/source/alarms_and_conditions/client_alarm_tools_acknowledge_all_conditions.ts +2 -0
- package/source/index.ts +1 -1
- package/source/private/client_base_impl.ts +8 -3
- package/source/private/client_publish_engine.ts +3 -0
- package/source/private/client_session_impl.ts +1 -1
- package/source/private/client_subscription_impl.ts +1 -0
- package/source/reconnection.ts +14 -6
package/source/index.ts
CHANGED
|
@@ -37,7 +37,7 @@ export const utils = utils1;
|
|
|
37
37
|
import * as crypto_util1 from "node-opcua-crypto";
|
|
38
38
|
export const crypto_utils = crypto_util1;
|
|
39
39
|
|
|
40
|
-
export { hexDump } from "node-opcua-debug";
|
|
40
|
+
export { hexDump, LogLevel, setLogLevel, setDebugLogger, setWarningLogger, setErrorLogger } from "node-opcua-debug";
|
|
41
41
|
|
|
42
42
|
///
|
|
43
43
|
export {
|
|
@@ -123,6 +123,7 @@ function __findEndpoint(this: OPCUAClientBase, endpointUrl: string, params: Find
|
|
|
123
123
|
// rebind backoff handler
|
|
124
124
|
masterClient.listeners("backoff").forEach((handler: any) => client.on("backoff", handler));
|
|
125
125
|
|
|
126
|
+
// istanbul ignore next
|
|
126
127
|
if (doDebug) {
|
|
127
128
|
client.on("backoff", (retryCount: number, delay: number) => {
|
|
128
129
|
debugLog(
|
|
@@ -146,7 +147,7 @@ function __findEndpoint(this: OPCUAClientBase, endpointUrl: string, params: Find
|
|
|
146
147
|
" (err =" +
|
|
147
148
|
err.message +
|
|
148
149
|
")";
|
|
149
|
-
|
|
150
|
+
warningLog(err.message);
|
|
150
151
|
}
|
|
151
152
|
return innerCallback(err);
|
|
152
153
|
});
|
|
@@ -231,8 +232,9 @@ function _verify_serverCertificate(
|
|
|
231
232
|
return callback(err);
|
|
232
233
|
}
|
|
233
234
|
if (status !== StatusCodes.Good) {
|
|
234
|
-
//
|
|
235
|
+
// istanbul ignore next
|
|
235
236
|
if (doDebug) {
|
|
237
|
+
// do it again for debug purposes
|
|
236
238
|
certificateManager.verifyCertificate(serverCertificate, (err1: Error | null, status1?: VerificationStatus) => {
|
|
237
239
|
debugLog(status1);
|
|
238
240
|
});
|
|
@@ -384,7 +386,7 @@ export class ClientBaseImpl extends OPCUASecureObject implements OPCUAClientBase
|
|
|
384
386
|
private _instanceNumber: number;
|
|
385
387
|
private _transportSettings: TransportSettings;
|
|
386
388
|
private _transportTimeout?: number;
|
|
387
|
-
|
|
389
|
+
|
|
388
390
|
public clientCertificateManager: OPCUACertificateManager;
|
|
389
391
|
|
|
390
392
|
public isUnusable() {
|
|
@@ -404,6 +406,7 @@ export class ClientBaseImpl extends OPCUASecureObject implements OPCUAClientBase
|
|
|
404
406
|
this._internalState = internalState;
|
|
405
407
|
}
|
|
406
408
|
public emit(eventName: string | symbol, ...others: any[]): boolean {
|
|
409
|
+
// istanbul ignore next
|
|
407
410
|
if (doDebug) {
|
|
408
411
|
debugLog(chalk.cyan(` Client ${this._instanceNumber} ${this.clientName} emitting `), chalk.magentaBright(eventName));
|
|
409
412
|
}
|
|
@@ -1455,6 +1458,7 @@ export class ClientBaseImpl extends OPCUASecureObject implements OPCUAClientBase
|
|
|
1455
1458
|
this._byteRead += this._secureChannel.bytesRead;
|
|
1456
1459
|
this._transactionsPerformed += this._secureChannel.transactionsPerformed;
|
|
1457
1460
|
this._timedOutRequestCount += this._secureChannel.timedOutRequestCount;
|
|
1461
|
+
// istanbul ignore next
|
|
1458
1462
|
if (doDebug) {
|
|
1459
1463
|
const h = `Client ${this._instanceNumber} ${this.clientName}`;
|
|
1460
1464
|
debugLog(chalk.cyan(`${h} byteWritten = `), this._byteWritten);
|
|
@@ -1466,6 +1470,7 @@ export class ClientBaseImpl extends OPCUASecureObject implements OPCUAClientBase
|
|
|
1466
1470
|
}
|
|
1467
1471
|
private _destroy_secure_channel() {
|
|
1468
1472
|
if (this._secureChannel) {
|
|
1473
|
+
// istanbul ignore next
|
|
1469
1474
|
if (doDebug) {
|
|
1470
1475
|
debugLog(
|
|
1471
1476
|
" DESTROYING SECURE CHANNEL (isTransactionInProgress ?",
|
|
@@ -337,6 +337,7 @@ export class ClientSidePublishEngine {
|
|
|
337
337
|
warningLog(" => nbMaxPublishRequestsAcceptedByServer =", this.nbMaxPublishRequestsAcceptedByServer);
|
|
338
338
|
}
|
|
339
339
|
} else {
|
|
340
|
+
// istanbul ignore next
|
|
340
341
|
if (doDebug) {
|
|
341
342
|
debugLog(chalk.cyan("ClientSidePublishEngine.prototype.internalSendPublishRequest callback "));
|
|
342
343
|
}
|
|
@@ -390,6 +391,7 @@ export class ClientSidePublishEngine {
|
|
|
390
391
|
// delegate notificationData to the subscription callback
|
|
391
392
|
subscription.onNotificationMessage(notificationMessage);
|
|
392
393
|
} catch (err) {
|
|
394
|
+
// istanbul ignore next
|
|
393
395
|
if (doDebug) {
|
|
394
396
|
debugLog(err);
|
|
395
397
|
debugLog("Exception in onNotificationMessage");
|
|
@@ -418,6 +420,7 @@ export class ClientSidePublishEngine {
|
|
|
418
420
|
|
|
419
421
|
// istanbul ignore next
|
|
420
422
|
if (doDebug) {
|
|
423
|
+
// istanbul ignore next
|
|
421
424
|
debugLog(
|
|
422
425
|
chalk.bgCyan.yellow.bold(" republish Request for subscription"),
|
|
423
426
|
request.subscriptionId,
|
|
@@ -2061,7 +2061,7 @@ export class ClientSessionImpl extends EventEmitter implements ClientSession {
|
|
|
2061
2061
|
str += "\n timeout.................. " + this.timeout + "ms" + timeoutInfo;
|
|
2062
2062
|
str += "\n serverNonce.............. " + (this.serverNonce ? this.serverNonce!.toString("hex") : "");
|
|
2063
2063
|
str += "\n serverCertificate........ " + buffer_ellipsis(this.serverCertificate);
|
|
2064
|
-
|
|
2064
|
+
str += "\n serverSignature.......... " + this.serverSignature;
|
|
2065
2065
|
str += "\n lastRequestSentTime...... " + new Date(this.lastRequestSentTime).toISOString() + " (" + lap1 + ")";
|
|
2066
2066
|
str += "\n lastResponseReceivedTime. " + new Date(this.lastResponseReceivedTime).toISOString() + " (" + lap2 + ")";
|
|
2067
2067
|
str += "\n isReconnecting........... " + this.isReconnecting;
|
|
@@ -760,6 +760,7 @@ export class ClientSubscriptionImpl extends EventEmitter implements ClientSubscr
|
|
|
760
760
|
displayKeepAliveWarning(this.session.timeout, this.maxKeepAliveCount, this.publishingInterval);
|
|
761
761
|
ClientSubscription.ignoreNextWarning = false;
|
|
762
762
|
|
|
763
|
+
// istanbul ignore next
|
|
763
764
|
if (doDebug) {
|
|
764
765
|
debugLog(chalk.yellow.bold("registering callback"));
|
|
765
766
|
debugLog(chalk.yellow.bold("publishingInterval "), this.publishingInterval);
|
package/source/reconnection.ts
CHANGED
|
@@ -174,12 +174,14 @@ function repair_client_session_by_recreating_a_new_session(
|
|
|
174
174
|
// and may be upgraded in between, we have to invalidate the extra data type manager
|
|
175
175
|
invalidateExtraDataTypeManager(session);
|
|
176
176
|
|
|
177
|
+
// istanbul ignore next
|
|
177
178
|
if (doDebug) {
|
|
178
|
-
|
|
179
|
+
debugLog(" repairing client session by_recreating a new session for old session ", session.sessionId.toString());
|
|
179
180
|
}
|
|
180
181
|
|
|
181
182
|
// TO DO : it is possible that session is already closed while we get there
|
|
182
183
|
if (session.hasBeenClosed()) {
|
|
184
|
+
// istanbul ignore next
|
|
183
185
|
doDebug && debugLog(chalk.bgWhite.red("Aborting reactivation of old session because user requested session to be closed"));
|
|
184
186
|
return callback(new Error("reconnection cancelled due to session termination"));
|
|
185
187
|
}
|
|
@@ -194,6 +196,7 @@ function repair_client_session_by_recreating_a_new_session(
|
|
|
194
196
|
if (session.hasBeenClosed()) {
|
|
195
197
|
return innerCallback(new Error("Cannot complete subscription republish due to session termination"));
|
|
196
198
|
}
|
|
199
|
+
// istanbul ignore next
|
|
197
200
|
doDebug && debugLog(chalk.bgWhite.red(" => suspend old session publish engine...."));
|
|
198
201
|
session.getPublishEngine().suspend(true);
|
|
199
202
|
innerCallback();
|
|
@@ -218,6 +221,7 @@ function repair_client_session_by_recreating_a_new_session(
|
|
|
218
221
|
newSession,
|
|
219
222
|
newSession.userIdentityInfo!,
|
|
220
223
|
(err: Error | null, session1?: ClientSessionImpl) => {
|
|
224
|
+
// istanbul ignore next
|
|
221
225
|
doDebug && debugLog(" => activating a new session .... Done err=", err ? err.message : "null");
|
|
222
226
|
if (err) {
|
|
223
227
|
doDebug &&
|
|
@@ -235,7 +239,9 @@ function repair_client_session_by_recreating_a_new_session(
|
|
|
235
239
|
if (err2) {
|
|
236
240
|
warningLog("closing session", err2.message);
|
|
237
241
|
}
|
|
242
|
+
// istanbul ignore next
|
|
238
243
|
doDebug && debugLog("the temporary replacement session is now closed");
|
|
244
|
+
// istanbul ignore next
|
|
239
245
|
doDebug && debugLog(" err ", err.message, "propagated upwards");
|
|
240
246
|
innerCallback(err);
|
|
241
247
|
});
|
|
@@ -459,7 +465,6 @@ export function repair_client_session(client: IClientBase, session: ClientSessio
|
|
|
459
465
|
" => Let's retry"
|
|
460
466
|
);
|
|
461
467
|
if (!session.hasBeenClosed()) {
|
|
462
|
-
|
|
463
468
|
const delay = 2000;
|
|
464
469
|
errorLog(chalk.red(`... will retry session repair... in ${delay} ms`));
|
|
465
470
|
setTimeout(() => {
|
|
@@ -468,24 +473,27 @@ export function repair_client_session(client: IClientBase, session: ClientSessio
|
|
|
468
473
|
}, delay);
|
|
469
474
|
return;
|
|
470
475
|
} else {
|
|
471
|
-
|
|
476
|
+
errorLog(chalk.red("session restoration should be interrupted because session has been closed forcefully"));
|
|
472
477
|
// session does not need to be repaired anymore
|
|
473
478
|
callback();
|
|
474
|
-
}
|
|
479
|
+
}
|
|
475
480
|
return;
|
|
476
481
|
}
|
|
477
482
|
|
|
478
483
|
privateSession._reconnecting.reconnecting = false;
|
|
479
484
|
|
|
480
|
-
//
|
|
485
|
+
// istanbul ignore next
|
|
481
486
|
doDebug && debugLog(chalk.yellow("session has been restored"), session.sessionId.toString());
|
|
482
|
-
|
|
487
|
+
|
|
483
488
|
session.emit("session_restored");
|
|
484
489
|
const otherCallbacks = privateSession._reconnecting.pendingCallbacks;
|
|
485
490
|
privateSession._reconnecting.pendingCallbacks = [];
|
|
486
491
|
|
|
487
492
|
// re-inject element in queue
|
|
493
|
+
|
|
494
|
+
// istanbul ignore next
|
|
488
495
|
doDebug && debugLog(chalk.yellow("re-injecting transaction queue"), transactionQueue.length);
|
|
496
|
+
|
|
489
497
|
transactionQueue.forEach((e: any) => privateSession.pendingTransactions.push(e));
|
|
490
498
|
otherCallbacks.forEach((c: EmptyCallback) => c(err));
|
|
491
499
|
callback(err);
|