node-opcua-client 2.57.0 → 2.61.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/dist/client_session.d.ts +2 -2
- package/dist/opcua_client.d.ts +4 -0
- package/dist/opcua_client.js +14 -0
- package/dist/opcua_client.js.map +1 -1
- package/dist/private/client_base_impl.js +13 -2
- package/dist/private/client_base_impl.js.map +1 -1
- package/dist/private/client_publish_engine.js +14 -5
- package/dist/private/client_publish_engine.js.map +1 -1
- package/dist/private/client_session_impl.js +1 -3
- package/dist/private/client_session_impl.js.map +1 -1
- package/dist/private/opcua_client_impl.d.ts +33 -0
- package/dist/private/opcua_client_impl.js +83 -9
- package/dist/private/opcua_client_impl.js.map +1 -1
- package/dist/reconnection.js +31 -15
- package/dist/reconnection.js.map +1 -1
- package/dist/tools/read_history_server_capabilities.js +1 -1
- package/dist/tools/read_history_server_capabilities.js.map +1 -1
- package/package.json +40 -40
- package/source/client_session.ts +2 -2
- package/source/opcua_client.ts +13 -0
- package/source/private/client_base_impl.ts +13 -2
- package/source/private/client_publish_engine.ts +13 -6
- package/source/private/client_session_impl.ts +2 -4
- package/source/private/opcua_client_impl.ts +101 -10
- package/source/reconnection.ts +35 -17
- package/source/tools/read_history_server_capabilities.ts +1 -1
package/source/reconnection.ts
CHANGED
|
@@ -8,7 +8,7 @@ import * as chalk from "chalk";
|
|
|
8
8
|
import { assert } from "node-opcua-assert";
|
|
9
9
|
import { checkDebugFlag, make_debugLog, make_errorLog, make_warningLog } from "node-opcua-debug";
|
|
10
10
|
import { TransferSubscriptionsRequest, TransferSubscriptionsResponse } from "node-opcua-service-subscription";
|
|
11
|
-
import { StatusCodes } from "node-opcua-status-code";
|
|
11
|
+
import { CallbackT, StatusCodes } from "node-opcua-status-code";
|
|
12
12
|
import { ErrorCallback } from "node-opcua-status-code";
|
|
13
13
|
|
|
14
14
|
import { SubscriptionId } from "./client_session";
|
|
@@ -133,6 +133,33 @@ function _ask_for_subscription_republish(session: ClientSessionImpl, callback: (
|
|
|
133
133
|
});
|
|
134
134
|
}
|
|
135
135
|
|
|
136
|
+
function create_session_and_repeat_if_failed(
|
|
137
|
+
client: IClientBase,
|
|
138
|
+
session: ClientSessionImpl,
|
|
139
|
+
callback: CallbackT<ClientSessionImpl>
|
|
140
|
+
) {
|
|
141
|
+
if (session.hasBeenClosed()) {
|
|
142
|
+
return callback(new Error("Cannot complete subscription republish due to session termination"));
|
|
143
|
+
}
|
|
144
|
+
debugLog(chalk.bgWhite.red(" => creating a new session ...."));
|
|
145
|
+
// create new session, based on old session,
|
|
146
|
+
// so we can reuse subscriptions data
|
|
147
|
+
client.__createSession_step2(session, (err: Error | null, session1?: ClientSessionImpl) => {
|
|
148
|
+
debugLog(chalk.bgWhite.cyan(" => creating a new session (based on old session data).... Done"));
|
|
149
|
+
if (!err && session1) {
|
|
150
|
+
const newSession = session1;
|
|
151
|
+
assert(session === session1, "session should have been recycled");
|
|
152
|
+
callback(err, newSession);
|
|
153
|
+
return;
|
|
154
|
+
} else {
|
|
155
|
+
setTimeout(() => {
|
|
156
|
+
create_session_and_repeat_if_failed(client, session, callback);
|
|
157
|
+
}, 1000);
|
|
158
|
+
return;
|
|
159
|
+
}
|
|
160
|
+
callback(err);
|
|
161
|
+
});
|
|
162
|
+
}
|
|
136
163
|
function repair_client_session_by_recreating_a_new_session(
|
|
137
164
|
client: IClientBase,
|
|
138
165
|
session: ClientSessionImpl,
|
|
@@ -164,20 +191,11 @@ function repair_client_session_by_recreating_a_new_session(
|
|
|
164
191
|
},
|
|
165
192
|
|
|
166
193
|
function create_new_session(innerCallback: ErrorCallback) {
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
debugLog(chalk.bgWhite.red(" => creating a new session ...."));
|
|
172
|
-
// create new session, based on old session,
|
|
173
|
-
// so we can reuse subscriptions data
|
|
174
|
-
client.__createSession_step2(session, (err: Error | null, session1?: ClientSessionImpl) => {
|
|
175
|
-
debugLog(chalk.bgWhite.cyan(" => creating a new session (based on old session data).... Done"));
|
|
176
|
-
if (!err && session1) {
|
|
177
|
-
newSession = session1;
|
|
178
|
-
assert(session === session1, "session should have been recycled");
|
|
194
|
+
create_session_and_repeat_if_failed(client, session, (err?: Error | null, _newSession?: ClientSessionImpl) => {
|
|
195
|
+
if (_newSession) {
|
|
196
|
+
newSession = _newSession;
|
|
179
197
|
}
|
|
180
|
-
innerCallback(err
|
|
198
|
+
innerCallback(err || undefined);
|
|
181
199
|
});
|
|
182
200
|
},
|
|
183
201
|
|
|
@@ -386,8 +404,8 @@ export function repair_client_session(client: IClientBase, session: ClientSessio
|
|
|
386
404
|
_repair_client_session(client, session, (err) => {
|
|
387
405
|
privateSession._reconnecting.reconnecting = false;
|
|
388
406
|
if (err) {
|
|
389
|
-
|
|
390
|
-
|
|
407
|
+
errorLog(chalk.red("SESSION RESTORED HAS FAILED! retrying"), err.message, session.sessionId.toString());
|
|
408
|
+
return _repair_client_session(client, session, callback);
|
|
391
409
|
}
|
|
392
410
|
debugLog(chalk.yellow("SESSION RESTORED"), session.sessionId.toString());
|
|
393
411
|
session.emit("session_restored");
|
|
@@ -413,7 +431,7 @@ export function repair_client_sessions(client: IClientBase, callback: (err?: Err
|
|
|
413
431
|
repair_client_session(client, session as ClientSessionImpl, next);
|
|
414
432
|
},
|
|
415
433
|
(err) => {
|
|
416
|
-
|
|
434
|
+
err && errorLog("sessions reactivation completed: err ", err ? err.message : "null");
|
|
417
435
|
return callback(err!);
|
|
418
436
|
}
|
|
419
437
|
);
|
|
@@ -91,7 +91,7 @@ export function readHistoryServerCapabilities(
|
|
|
91
91
|
const nodeIds = results.map((innerResult: BrowsePathResult) =>
|
|
92
92
|
innerResult.statusCode === StatusCodes.Good && innerResult.targets
|
|
93
93
|
? innerResult.targets[0].targetId
|
|
94
|
-
: NodeId
|
|
94
|
+
: new NodeId()
|
|
95
95
|
);
|
|
96
96
|
|
|
97
97
|
const nodesToRead: ReadValueIdOptions[] = nodeIds.map((nodeId: NodeId) => ({
|