node-opcua-transport 2.99.0 → 2.101.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/source/client_tcp_transport.d.ts +4 -9
- package/dist/source/client_tcp_transport.js +36 -70
- package/dist/source/client_tcp_transport.js.map +1 -1
- package/dist/source/server_tcp_transport.d.ts +3 -15
- package/dist/source/server_tcp_transport.js +38 -40
- package/dist/source/server_tcp_transport.js.map +1 -1
- package/dist/source/tcp_transport.d.ts +44 -28
- package/dist/source/tcp_transport.js +155 -110
- package/dist/source/tcp_transport.js.map +1 -1
- package/dist/test_helpers/ITransportPair.d.ts +7 -0
- package/dist/test_helpers/ITransportPair.js +3 -0
- package/dist/test_helpers/ITransportPair.js.map +1 -0
- package/dist/test_helpers/fake_server.d.ts +2 -0
- package/dist/test_helpers/fake_server.js +3 -0
- package/dist/test_helpers/fake_server.js.map +1 -1
- package/dist/test_helpers/half_com_channel.d.ts +17 -10
- package/dist/test_helpers/half_com_channel.js +63 -4
- package/dist/test_helpers/half_com_channel.js.map +1 -1
- package/dist/test_helpers/index.d.ts +2 -2
- package/dist/test_helpers/index.js +2 -2
- package/dist/test_helpers/index.js.map +1 -1
- package/dist/test_helpers/{direct_transport.d.ts → transport_pair_direct.d.ts} +2 -6
- package/dist/test_helpers/{direct_transport.js → transport_pair_direct.js} +11 -18
- package/dist/test_helpers/transport_pair_direct.js.map +1 -0
- package/dist/test_helpers/transport_pair_socket.d.ts +14 -0
- package/dist/test_helpers/transport_pair_socket.js +33 -0
- package/dist/test_helpers/transport_pair_socket.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -2
- package/source/client_tcp_transport.ts +55 -88
- package/source/server_tcp_transport.ts +46 -49
- package/source/tcp_transport.ts +224 -155
- package/dist/test_helpers/direct_transport.js.map +0 -1
- package/dist/test_helpers/socket_transport.d.ts +0 -10
- package/dist/test_helpers/socket_transport.js +0 -31
- package/dist/test_helpers/socket_transport.js.map +0 -1
|
@@ -4,17 +4,14 @@ import { TCP_transport } from "./tcp_transport";
|
|
|
4
4
|
import { AcknowledgeMessage } from "./AcknowledgeMessage";
|
|
5
5
|
export interface ClientTCP_transport {
|
|
6
6
|
on(eventName: "chunk", eventHandler: (messageChunk: Buffer) => void): this;
|
|
7
|
-
on(eventName: "socket_closed", eventHandler: (err: Error | null) => void): this;
|
|
8
7
|
on(eventName: "close", eventHandler: (err: Error | null) => void): this;
|
|
9
8
|
on(eventName: "connection_break", eventHandler: () => void): this;
|
|
10
9
|
on(eventName: "connect", eventHandler: () => void): this;
|
|
11
10
|
once(eventName: "chunk", eventHandler: (messageChunk: Buffer) => void): this;
|
|
12
|
-
once(eventName: "socket_closed", eventHandler: (err: Error | null) => void): this;
|
|
13
11
|
once(eventName: "close", eventHandler: (err: Error | null) => void): this;
|
|
14
12
|
once(eventName: "connection_break", eventHandler: () => void): this;
|
|
15
13
|
once(eventName: "connect", eventHandler: () => void): this;
|
|
16
14
|
emit(eventName: "chunk", messageChunk: Buffer): boolean;
|
|
17
|
-
emit(eventName: "socket_closed", err?: Error | null): boolean;
|
|
18
15
|
emit(eventName: "close", err?: Error | null): boolean;
|
|
19
16
|
emit(eventName: "connection_break"): boolean;
|
|
20
17
|
emit(eventName: "connect"): boolean;
|
|
@@ -40,7 +37,7 @@ export interface TransportSettingsOptions {
|
|
|
40
37
|
*
|
|
41
38
|
* transport.timeout = 10000;
|
|
42
39
|
*
|
|
43
|
-
* transport.connect(function(err)) {
|
|
40
|
+
* transport.connect(function (err)) {
|
|
44
41
|
* if (err) {
|
|
45
42
|
* // cannot connect
|
|
46
43
|
* } else {
|
|
@@ -50,16 +47,16 @@ export interface TransportSettingsOptions {
|
|
|
50
47
|
* });
|
|
51
48
|
* ....
|
|
52
49
|
*
|
|
53
|
-
* transport.write(message_chunk,'F');
|
|
50
|
+
* transport.write(message_chunk, 'F');
|
|
54
51
|
*
|
|
55
52
|
* ....
|
|
56
53
|
*
|
|
57
|
-
* transport.on("chunk",function(message_chunk) {
|
|
54
|
+
* transport.on("chunk", function (message_chunk) {
|
|
58
55
|
* // do something with chunk from server...
|
|
59
56
|
* });
|
|
60
57
|
*
|
|
61
58
|
*
|
|
62
|
-
*
|
|
59
|
+
* ```
|
|
63
60
|
*
|
|
64
61
|
*
|
|
65
62
|
*/
|
|
@@ -72,14 +69,12 @@ export declare class ClientTCP_transport extends TCP_transport {
|
|
|
72
69
|
serverUri: string;
|
|
73
70
|
numberOfRetry: number;
|
|
74
71
|
parameters?: AcknowledgeMessage;
|
|
75
|
-
private connected;
|
|
76
72
|
private _counter;
|
|
77
73
|
private _helloSettings;
|
|
78
74
|
constructor(transportSettings?: TransportSettingsOptions);
|
|
79
75
|
getTransportSettings(): TransportSettingsOptions;
|
|
80
76
|
dispose(): void;
|
|
81
77
|
connect(endpointUrl: string, callback: ErrorCallback): void;
|
|
82
|
-
protected on_socket_ended(err: Error | null): void;
|
|
83
78
|
private _handle_ACK_response;
|
|
84
79
|
private _send_HELLO_request;
|
|
85
80
|
private _on_ACK_response;
|
|
@@ -22,7 +22,7 @@ const debugLog = debug.make_debugLog(__filename);
|
|
|
22
22
|
const warningLog = debug.make_warningLog(__filename);
|
|
23
23
|
const errorLog = debug.make_errorLog(__filename);
|
|
24
24
|
const gHostname = os.hostname();
|
|
25
|
-
function createClientSocket(endpointUrl) {
|
|
25
|
+
function createClientSocket(endpointUrl, timeout) {
|
|
26
26
|
// create a socket based on Url
|
|
27
27
|
const ep = (0, tools_1.parseEndpointUrl)(endpointUrl);
|
|
28
28
|
const port = parseInt(ep.port, 10);
|
|
@@ -30,19 +30,17 @@ function createClientSocket(endpointUrl) {
|
|
|
30
30
|
let socket;
|
|
31
31
|
switch (ep.protocol) {
|
|
32
32
|
case "opc.tcp:":
|
|
33
|
-
socket = (0, net_1.createConnection)({ host: hostname, port })
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
socket.setNoDelay(true);
|
|
33
|
+
socket = (0, net_1.createConnection)({ host: hostname, port, timeout }, () => {
|
|
34
|
+
doDebug && debugLog(`connected to server! ${hostname}:${port} timeout:${timeout} `);
|
|
35
|
+
});
|
|
37
36
|
return socket;
|
|
38
37
|
case "fake:":
|
|
39
|
-
socket = (0, tcp_transport_1.getFakeTransport)();
|
|
40
38
|
(0, node_opcua_assert_1.assert)(ep.protocol === "fake:", " Unsupported transport protocol");
|
|
41
|
-
|
|
39
|
+
socket = (0, tcp_transport_1.getFakeTransport)();
|
|
42
40
|
return socket;
|
|
43
41
|
case "websocket:":
|
|
44
42
|
case "http:":
|
|
45
|
-
case "https:
|
|
43
|
+
case "https:":
|
|
46
44
|
default: {
|
|
47
45
|
const msg = "[NODE-OPCUA-E05] this transport protocol is not supported :" + ep.protocol;
|
|
48
46
|
errorLog(msg);
|
|
@@ -65,7 +63,7 @@ function createClientSocket(endpointUrl) {
|
|
|
65
63
|
*
|
|
66
64
|
* transport.timeout = 10000;
|
|
67
65
|
*
|
|
68
|
-
* transport.connect(function(err)) {
|
|
66
|
+
* transport.connect(function (err)) {
|
|
69
67
|
* if (err) {
|
|
70
68
|
* // cannot connect
|
|
71
69
|
* } else {
|
|
@@ -75,23 +73,22 @@ function createClientSocket(endpointUrl) {
|
|
|
75
73
|
* });
|
|
76
74
|
* ....
|
|
77
75
|
*
|
|
78
|
-
* transport.write(message_chunk,'F');
|
|
76
|
+
* transport.write(message_chunk, 'F');
|
|
79
77
|
*
|
|
80
78
|
* ....
|
|
81
79
|
*
|
|
82
|
-
* transport.on("chunk",function(message_chunk) {
|
|
80
|
+
* transport.on("chunk", function (message_chunk) {
|
|
83
81
|
* // do something with chunk from server...
|
|
84
82
|
* });
|
|
85
83
|
*
|
|
86
84
|
*
|
|
87
|
-
*
|
|
85
|
+
* ```
|
|
88
86
|
*
|
|
89
87
|
*
|
|
90
88
|
*/
|
|
91
89
|
class ClientTCP_transport extends tcp_transport_1.TCP_transport {
|
|
92
90
|
constructor(transportSettings) {
|
|
93
91
|
super();
|
|
94
|
-
this.connected = false;
|
|
95
92
|
this.endpointUrl = "";
|
|
96
93
|
this.serverUri = "";
|
|
97
94
|
this._counter = 0;
|
|
@@ -113,9 +110,7 @@ class ClientTCP_transport extends tcp_transport_1.TCP_transport {
|
|
|
113
110
|
}
|
|
114
111
|
dispose() {
|
|
115
112
|
/* istanbul ignore next */
|
|
116
|
-
|
|
117
|
-
debugLog(" ClientTCP_transport disposed");
|
|
118
|
-
}
|
|
113
|
+
doDebug && debugLog(" ClientTCP_transport disposed");
|
|
119
114
|
super.dispose();
|
|
120
115
|
}
|
|
121
116
|
connect(endpointUrl, callback) {
|
|
@@ -125,31 +120,32 @@ class ClientTCP_transport extends tcp_transport_1.TCP_transport {
|
|
|
125
120
|
this.endpointUrl = endpointUrl;
|
|
126
121
|
this.serverUri = "urn:" + gHostname + ":Sample";
|
|
127
122
|
/* istanbul ignore next */
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
}
|
|
123
|
+
doDebug && debugLog(chalk.cyan("ClientTCP_transport#connect(endpointUrl = " + endpointUrl + ")"));
|
|
124
|
+
let socket = null;
|
|
131
125
|
try {
|
|
132
|
-
|
|
126
|
+
socket = createClientSocket(endpointUrl, this.timeout);
|
|
133
127
|
}
|
|
134
128
|
catch (err) {
|
|
135
129
|
/* istanbul ignore next */
|
|
136
|
-
|
|
137
|
-
debugLog("CreateClientSocket has failed");
|
|
138
|
-
}
|
|
130
|
+
doDebug && debugLog("CreateClientSocket has failed");
|
|
139
131
|
return callback(err);
|
|
140
132
|
}
|
|
133
|
+
/**
|
|
134
|
+
*
|
|
135
|
+
*/
|
|
141
136
|
const _on_socket_error_after_connection = (err) => {
|
|
142
137
|
/* istanbul ignore next */
|
|
143
|
-
|
|
144
|
-
debugLog(" _on_socket_error_after_connection ClientTCP_transport Socket Error", err.message);
|
|
145
|
-
}
|
|
138
|
+
doDebug && debugLog(" _on_socket_error_after_connection ClientTCP_transport Socket Error", err.message);
|
|
146
139
|
// EPIPE : EPIPE (Broken pipe): A write on a pipe, socket, or FIFO for which there is no process to read the
|
|
147
140
|
// data. Commonly encountered at the net and http layers, indicative that the remote side of the stream
|
|
148
141
|
// being written to has been closed.
|
|
149
142
|
// ECONNRESET (Connection reset by peer): A connection was forcibly closed by a peer. This normally results
|
|
150
143
|
// from a loss of the connection on the remote socket due to a timeout or reboot. Commonly encountered
|
|
151
144
|
// via the http and net module
|
|
152
|
-
|
|
145
|
+
// socket termination could happen:
|
|
146
|
+
// * when the socket times out (lost of connection, network outage, etc...)
|
|
147
|
+
// * or, when the server abruptly disconnects the socket ( in case of invalid communication for instance)
|
|
148
|
+
if (err.message.match(/ECONNRESET|EPIPE|premature socket termination/)) {
|
|
153
149
|
/**
|
|
154
150
|
* @event connection_break
|
|
155
151
|
*
|
|
@@ -159,9 +155,7 @@ class ClientTCP_transport extends tcp_transport_1.TCP_transport {
|
|
|
159
155
|
};
|
|
160
156
|
const _on_socket_connect = () => {
|
|
161
157
|
/* istanbul ignore next */
|
|
162
|
-
|
|
163
|
-
debugLog("entering _on_socket_connect");
|
|
164
|
-
}
|
|
158
|
+
doDebug && debugLog("entering _on_socket_connect");
|
|
165
159
|
_remove_connect_listeners();
|
|
166
160
|
this._perform_HEL_ACK_transaction((err) => {
|
|
167
161
|
if (!err) {
|
|
@@ -171,7 +165,6 @@ class ClientTCP_transport extends tcp_transport_1.TCP_transport {
|
|
|
171
165
|
}
|
|
172
166
|
// install error handler to detect connection break
|
|
173
167
|
this._socket.on("error", _on_socket_error_after_connection);
|
|
174
|
-
this.connected = true;
|
|
175
168
|
/**
|
|
176
169
|
* notify the observers that the transport is connected (the socket is connected and the the HEL/ACK
|
|
177
170
|
* transaction has been done)
|
|
@@ -189,18 +182,15 @@ class ClientTCP_transport extends tcp_transport_1.TCP_transport {
|
|
|
189
182
|
const _on_socket_error_for_connect = (err) => {
|
|
190
183
|
// this handler will catch attempt to connect to an inaccessible address.
|
|
191
184
|
/* istanbul ignore next */
|
|
192
|
-
|
|
193
|
-
debugLog(chalk.cyan("ClientTCP_transport#connect - _on_socket_error_for_connect"), err.message);
|
|
194
|
-
}
|
|
185
|
+
doDebug && debugLog(chalk.cyan("ClientTCP_transport#connect - _on_socket_error_for_connect"), err.message);
|
|
195
186
|
(0, node_opcua_assert_1.assert)(err instanceof Error);
|
|
196
187
|
_remove_connect_listeners();
|
|
197
188
|
callback(err);
|
|
198
189
|
};
|
|
199
|
-
const _on_socket_end_for_connect = (
|
|
190
|
+
const _on_socket_end_for_connect = () => {
|
|
200
191
|
/* istanbul ignore next */
|
|
201
|
-
|
|
202
|
-
debugLog(chalk.cyan("ClientTCP_transport#connect -> _on_socket_end_for_connect Socket has been closed by server")
|
|
203
|
-
}
|
|
192
|
+
doDebug &&
|
|
193
|
+
debugLog(chalk.cyan("ClientTCP_transport#connect -> _on_socket_end_for_connect Socket has been closed by server"));
|
|
204
194
|
};
|
|
205
195
|
const _remove_connect_listeners = () => {
|
|
206
196
|
/* istanbul ignore next */
|
|
@@ -210,19 +200,10 @@ class ClientTCP_transport extends tcp_transport_1.TCP_transport {
|
|
|
210
200
|
this._socket.removeListener("error", _on_socket_error_for_connect);
|
|
211
201
|
this._socket.removeListener("end", _on_socket_end_for_connect);
|
|
212
202
|
};
|
|
203
|
+
this._install_socket(socket);
|
|
213
204
|
this._socket.once("error", _on_socket_error_for_connect);
|
|
214
205
|
this._socket.once("end", _on_socket_end_for_connect);
|
|
215
206
|
this._socket.once("connect", _on_socket_connect);
|
|
216
|
-
this._install_socket(this._socket);
|
|
217
|
-
}
|
|
218
|
-
on_socket_ended(err) {
|
|
219
|
-
debugLog("on_socket_ended", this.name, err ? err.message : "");
|
|
220
|
-
if (this.connected) {
|
|
221
|
-
super.on_socket_ended(err);
|
|
222
|
-
}
|
|
223
|
-
// if (this._socket) {
|
|
224
|
-
// this._socket.removeAllListeners();
|
|
225
|
-
// }
|
|
226
207
|
}
|
|
227
208
|
_handle_ACK_response(messageChunk, callback) {
|
|
228
209
|
const _stream = new node_opcua_binary_stream_1.BinaryStream(messageChunk);
|
|
@@ -242,9 +223,7 @@ class ClientTCP_transport extends tcp_transport_1.TCP_transport {
|
|
|
242
223
|
err = new Error("ACK: ERR received " + response.statusCode.toString() + " : " + response.reason);
|
|
243
224
|
err.statusCode = response.statusCode;
|
|
244
225
|
// istanbul ignore next
|
|
245
|
-
|
|
246
|
-
warningLog("receiving ERR instead of Ack", response.toString());
|
|
247
|
-
}
|
|
226
|
+
utils_1.doTraceHelloAck && warningLog("receiving ERR instead of Ack", response.toString());
|
|
248
227
|
callback(err);
|
|
249
228
|
}
|
|
250
229
|
else {
|
|
@@ -254,17 +233,13 @@ class ClientTCP_transport extends tcp_transport_1.TCP_transport {
|
|
|
254
233
|
this.parameters = response;
|
|
255
234
|
this.setLimits(response);
|
|
256
235
|
// istanbul ignore next
|
|
257
|
-
|
|
258
|
-
warningLog("receiving Ack\n", response.toString());
|
|
259
|
-
}
|
|
236
|
+
utils_1.doTraceHelloAck && warningLog("receiving Ack\n", response.toString());
|
|
260
237
|
callback();
|
|
261
238
|
}
|
|
262
239
|
}
|
|
263
240
|
_send_HELLO_request() {
|
|
264
241
|
/* istanbul ignore next */
|
|
265
|
-
|
|
266
|
-
debugLog("entering _send_HELLO_request");
|
|
267
|
-
}
|
|
242
|
+
doDebug && debugLog("entering _send_HELLO_request");
|
|
268
243
|
(0, node_opcua_assert_1.assert)(this._socket);
|
|
269
244
|
(0, node_opcua_assert_1.assert)(isFinite(this.protocolVersion));
|
|
270
245
|
(0, node_opcua_assert_1.assert)(this.endpointUrl.length > 0, " expecting a valid endpoint url");
|
|
@@ -280,17 +255,13 @@ class ClientTCP_transport extends tcp_transport_1.TCP_transport {
|
|
|
280
255
|
sendBufferSize
|
|
281
256
|
});
|
|
282
257
|
// istanbul ignore next
|
|
283
|
-
|
|
284
|
-
warningLog(`sending Hello\n ${helloMessage.toString()}`);
|
|
285
|
-
}
|
|
258
|
+
utils_1.doTraceHelloAck && warningLog(`sending Hello\n ${helloMessage.toString()} `);
|
|
286
259
|
const messageChunk = (0, tools_1.packTcpMessage)("HEL", helloMessage);
|
|
287
260
|
this._write_chunk(messageChunk);
|
|
288
261
|
}
|
|
289
262
|
_on_ACK_response(externalCallback, err, data) {
|
|
290
263
|
/* istanbul ignore next */
|
|
291
|
-
|
|
292
|
-
debugLog("entering _on_ACK_response");
|
|
293
|
-
}
|
|
264
|
+
doDebug && debugLog("entering _on_ACK_response");
|
|
294
265
|
(0, node_opcua_assert_1.assert)(typeof externalCallback === "function");
|
|
295
266
|
(0, node_opcua_assert_1.assert)(this._counter === 0, "Ack response should only be received once !");
|
|
296
267
|
this._counter += 1;
|
|
@@ -298,7 +269,6 @@ class ClientTCP_transport extends tcp_transport_1.TCP_transport {
|
|
|
298
269
|
externalCallback(err || new Error("no data"));
|
|
299
270
|
if (this._socket) {
|
|
300
271
|
this._socket.end();
|
|
301
|
-
// Xx this._socket.removeAllListeners();
|
|
302
272
|
}
|
|
303
273
|
}
|
|
304
274
|
else {
|
|
@@ -314,14 +284,10 @@ class ClientTCP_transport extends tcp_transport_1.TCP_transport {
|
|
|
314
284
|
(0, node_opcua_assert_1.assert)(typeof callback === "function");
|
|
315
285
|
this._counter = 0;
|
|
316
286
|
/* istanbul ignore next */
|
|
317
|
-
|
|
318
|
-
debugLog("entering _perform_HEL_ACK_transaction");
|
|
319
|
-
}
|
|
287
|
+
doDebug && debugLog("entering _perform_HEL_ACK_transaction");
|
|
320
288
|
this._install_one_time_message_receiver((err, data) => {
|
|
321
289
|
/* istanbul ignore next */
|
|
322
|
-
|
|
323
|
-
debugLog("before _on_ACK_response ", err ? err.message : "");
|
|
324
|
-
}
|
|
290
|
+
doDebug && debugLog("before _on_ACK_response ", err ? err.message : "");
|
|
325
291
|
this._on_ACK_response(callback, err, data);
|
|
326
292
|
});
|
|
327
293
|
this._send_HELLO_request();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client_tcp_transport.js","sourceRoot":"","sources":["../../source/client_tcp_transport.ts"],"names":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CAAC,CAAC;QACnE,IAAA,0BAAM,EAAC,OAAO,QAAQ,KAAK,UAAU,CAAC,CAAC;QACvC,IAAI,CAAC,QAAQ,GAAG,CAAC,CAAC;QAClB,0BAA0B;QAC1B,OAAO,IAAI,QAAQ,CAAC,uCAAuC,CAAC,CAAC;QAE7D,IAAI,CAAC,kCAAkC,CAAC,CAAC,GAAiB,EAAE,IAAa,EAAE,EAAE;YACzE,0BAA0B;YAC1B,OAAO,IAAI,QAAQ,CAAC,2BAA2B,EAAE,GAAG,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;YAEzE,IAAI,CAAC,gBAAgB,CAAC,QAAQ,EAAE,GAAG,EAAE,IAAI,CAAC,CAAC;QAC/C,CAAC,CAAC,CAAC;QACH,IAAI,CAAC,mBAAmB,EAAE,CAAC;IAC/B,CAAC;;AApQa,mCAAe,GAAG,CAAC,CAAC,CAAC,gBAAgB;AACrC,yCAAqB,GAAG,CAAC,CAAC,CAAC,gBAAgB;AAC3C,4CAAwB,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC;AAC1C,yCAAqB,GAAG,IAAI,GAAG,EAAE,GAAG,EAAE,CAAC,CAAC,YAAY;AAJzD,kDAAmB"}
|
|
@@ -1,23 +1,12 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
/// <reference types="node" />
|
|
3
|
-
/**
|
|
4
|
-
* @module node-opcua-transport
|
|
5
|
-
*/
|
|
6
|
-
import { Socket } from "net";
|
|
7
|
-
import { StatusCode } from "node-opcua-status-code";
|
|
8
2
|
import { ErrorCallback } from "node-opcua-status-code";
|
|
9
|
-
import { TCP_transport } from "./tcp_transport";
|
|
10
|
-
/**
|
|
11
|
-
* @class ServerTCP_transport
|
|
12
|
-
* @extends TCP_transport
|
|
13
|
-
* @constructor
|
|
14
|
-
*
|
|
15
|
-
*/
|
|
3
|
+
import { ISocketLike, TCP_transport } from "./tcp_transport";
|
|
16
4
|
export declare class ServerTCP_transport extends TCP_transport {
|
|
17
5
|
static throttleTime: number;
|
|
18
6
|
private _aborted;
|
|
19
7
|
private _helloReceived;
|
|
20
8
|
constructor();
|
|
9
|
+
toString(): string;
|
|
21
10
|
protected _write_chunk(messageChunk: Buffer): void;
|
|
22
11
|
/**
|
|
23
12
|
* Initialize the server transport.
|
|
@@ -35,8 +24,7 @@ export declare class ServerTCP_transport extends TCP_transport {
|
|
|
35
24
|
*
|
|
36
25
|
*
|
|
37
26
|
*/
|
|
38
|
-
init(socket:
|
|
39
|
-
abortWithError(statusCode: StatusCode, extraErrorDescription: string, callback: ErrorCallback): void;
|
|
27
|
+
init(socket: ISocketLike, callback: ErrorCallback): void;
|
|
40
28
|
private _abortWithError;
|
|
41
29
|
private _send_ACK_response;
|
|
42
30
|
private _install_HEL_message_receiver;
|
|
@@ -15,9 +15,10 @@ const tcp_transport_1 = require("./tcp_transport");
|
|
|
15
15
|
const tools_1 = require("./tools");
|
|
16
16
|
const utils_1 = require("./utils");
|
|
17
17
|
const hexDump = debug.hexDump;
|
|
18
|
-
const debugLog = debug.make_debugLog(
|
|
19
|
-
const errorLog = debug.make_errorLog(
|
|
20
|
-
const
|
|
18
|
+
const debugLog = debug.make_debugLog("TRANSPORT");
|
|
19
|
+
const errorLog = debug.make_errorLog("TRANSPORT");
|
|
20
|
+
const warningLog = debug.make_warningLog("TRANSPORT");
|
|
21
|
+
const doDebug = debug.checkDebugFlag("TRANSPORT");
|
|
21
22
|
function clamp_value(value, minVal, maxVal) {
|
|
22
23
|
(0, node_opcua_assert_1.assert)(minVal < maxVal);
|
|
23
24
|
if (value === 0) {
|
|
@@ -33,12 +34,6 @@ function clamp_value(value, minVal, maxVal) {
|
|
|
33
34
|
return value;
|
|
34
35
|
}
|
|
35
36
|
const minimumBufferSize = 8192;
|
|
36
|
-
/**
|
|
37
|
-
* @class ServerTCP_transport
|
|
38
|
-
* @extends TCP_transport
|
|
39
|
-
* @constructor
|
|
40
|
-
*
|
|
41
|
-
*/
|
|
42
37
|
class ServerTCP_transport extends tcp_transport_1.TCP_transport {
|
|
43
38
|
constructor() {
|
|
44
39
|
super();
|
|
@@ -49,6 +44,12 @@ class ServerTCP_transport extends tcp_transport_1.TCP_transport {
|
|
|
49
44
|
this.maxMessageSize = 4 * 1024;
|
|
50
45
|
this.receiveBufferSize = 4 * 1024;
|
|
51
46
|
}
|
|
47
|
+
toString() {
|
|
48
|
+
let str = super.toString();
|
|
49
|
+
str += "helloReceived...... = " + this._helloReceived + "\n";
|
|
50
|
+
str += "aborted............ = " + this._aborted + "\n";
|
|
51
|
+
return str;
|
|
52
|
+
}
|
|
52
53
|
_write_chunk(messageChunk) {
|
|
53
54
|
// istanbul ignore next
|
|
54
55
|
if (this.sendBufferSize > 0 && messageChunk.length > this.sendBufferSize) {
|
|
@@ -73,34 +74,35 @@ class ServerTCP_transport extends tcp_transport_1.TCP_transport {
|
|
|
73
74
|
*
|
|
74
75
|
*/
|
|
75
76
|
init(socket, callback) {
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
77
|
+
(0, node_opcua_assert_1.assert)(socket, "missing called!");
|
|
78
|
+
// istanbul ignore next
|
|
79
|
+
debugLog && debugLog(chalk.cyan("init socket"));
|
|
79
80
|
(0, node_opcua_assert_1.assert)(!this._socket, "init already called!");
|
|
80
81
|
(0, node_opcua_assert_1.assert)(typeof callback === "function", "expecting a valid callback ");
|
|
81
82
|
this._install_socket(socket);
|
|
82
83
|
this._install_HEL_message_receiver(callback);
|
|
83
84
|
}
|
|
84
|
-
abortWithError(statusCode, extraErrorDescription, callback) {
|
|
85
|
-
return this._abortWithError(statusCode, extraErrorDescription, callback);
|
|
86
|
-
}
|
|
87
85
|
_abortWithError(statusCode, extraErrorDescription, callback) {
|
|
86
|
+
var _a;
|
|
88
87
|
// When a fatal error occurs, the Server shall send an Error Message to the Client and
|
|
89
88
|
// closes the TransportConnection gracefully.
|
|
90
|
-
doDebug && debugLog(chalk.cyan("_abortWithError"));
|
|
89
|
+
doDebug && debugLog(this.name, chalk.cyan("_abortWithError", statusCode.toString(), extraErrorDescription));
|
|
91
90
|
/* istanbul ignore next */
|
|
92
91
|
if (this._aborted) {
|
|
92
|
+
errorLog("Internal Er!ror: _abortWithError already called! Should not happen here");
|
|
93
93
|
// already called
|
|
94
94
|
return callback(new Error(statusCode.name));
|
|
95
95
|
}
|
|
96
96
|
this._aborted = 1;
|
|
97
|
+
(_a = this._socket) === null || _a === void 0 ? void 0 : _a.setTimeout(0);
|
|
98
|
+
const err = new Error(extraErrorDescription + " StatusCode = " + statusCode.name);
|
|
99
|
+
this._theCloseError = err;
|
|
97
100
|
setTimeout(() => {
|
|
98
101
|
// send the error message and close the connection
|
|
99
102
|
this.sendErrorMessage(statusCode, statusCode.description);
|
|
100
|
-
this.
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
});
|
|
103
|
+
this.prematureTerminate(err, statusCode);
|
|
104
|
+
this._emitClose(err);
|
|
105
|
+
callback(err);
|
|
104
106
|
}, ServerTCP_transport.throttleTime);
|
|
105
107
|
}
|
|
106
108
|
_send_ACK_response(helloMessage) {
|
|
@@ -131,10 +133,11 @@ class ServerTCP_transport extends tcp_transport_1.TCP_transport {
|
|
|
131
133
|
});
|
|
132
134
|
// istanbul ignore next
|
|
133
135
|
if (utils_1.doTraceHelloAck) {
|
|
134
|
-
|
|
135
|
-
|
|
136
|
+
warningLog(`received Hello \n${helloMessage.toString()}`);
|
|
137
|
+
warningLog("Client accepts only message of size => ", this.maxMessageSize);
|
|
136
138
|
}
|
|
137
|
-
|
|
139
|
+
// istanbul ignore next
|
|
140
|
+
doDebug && debugLog("Client accepts only message of size => ", this.maxMessageSize);
|
|
138
141
|
const acknowledgeMessage = new AcknowledgeMessage_1.AcknowledgeMessage({
|
|
139
142
|
maxChunkCount: this.maxChunkCount,
|
|
140
143
|
maxMessageSize: this.maxMessageSize,
|
|
@@ -143,9 +146,7 @@ class ServerTCP_transport extends tcp_transport_1.TCP_transport {
|
|
|
143
146
|
sendBufferSize: this.sendBufferSize
|
|
144
147
|
});
|
|
145
148
|
// istanbul ignore next
|
|
146
|
-
|
|
147
|
-
console.log(`sending Ack \n${acknowledgeMessage.toString()}`);
|
|
148
|
-
}
|
|
149
|
+
utils_1.doTraceHelloAck && warningLog(`sending Ack \n${acknowledgeMessage.toString()}`);
|
|
149
150
|
const messageChunk = (0, tools_1.packTcpMessage)("ACK", acknowledgeMessage);
|
|
150
151
|
/* istanbul ignore next*/
|
|
151
152
|
if (doDebug) {
|
|
@@ -158,12 +159,11 @@ class ServerTCP_transport extends tcp_transport_1.TCP_transport {
|
|
|
158
159
|
this.write(messageChunk);
|
|
159
160
|
}
|
|
160
161
|
_install_HEL_message_receiver(callback) {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
}
|
|
162
|
+
// istanbul ignore next
|
|
163
|
+
doDebug && debugLog(chalk.cyan("_install_HEL_message_receiver "));
|
|
164
164
|
this._install_one_time_message_receiver((err, data) => {
|
|
165
165
|
if (err) {
|
|
166
|
-
|
|
166
|
+
callback(err);
|
|
167
167
|
}
|
|
168
168
|
else {
|
|
169
169
|
// handle the HEL message
|
|
@@ -172,9 +172,8 @@ class ServerTCP_transport extends tcp_transport_1.TCP_transport {
|
|
|
172
172
|
});
|
|
173
173
|
}
|
|
174
174
|
_on_HEL_message(data, callback) {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
}
|
|
175
|
+
// istanbul ignore next
|
|
176
|
+
doDebug && debugLog(chalk.cyan("_on_HEL_message"));
|
|
178
177
|
(0, node_opcua_assert_1.assert)(!this._helloReceived);
|
|
179
178
|
const stream = new node_opcua_binary_stream_1.BinaryStream(data);
|
|
180
179
|
const msgType = data.subarray(0, 3).toString("utf-8");
|
|
@@ -187,13 +186,14 @@ class ServerTCP_transport extends tcp_transport_1.TCP_transport {
|
|
|
187
186
|
try {
|
|
188
187
|
(0, node_opcua_assert_1.assert)(data.length >= 24);
|
|
189
188
|
const helloMessage = (0, tools_1.decodeMessage)(stream, HelloMessage_1.HelloMessage);
|
|
190
|
-
(0, node_opcua_assert_1.assert)(isFinite(this.protocolVersion));
|
|
191
189
|
// OPCUA Spec 1.03 part 6 - page 41
|
|
192
190
|
// The Server shall always accept versions greater than what it supports.
|
|
193
191
|
if (helloMessage.protocolVersion !== this.protocolVersion) {
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
`
|
|
192
|
+
// istanbul ignore next
|
|
193
|
+
doDebug &&
|
|
194
|
+
debugLog(`warning ! client sent helloMessage.protocolVersion = ` +
|
|
195
|
+
` 0x${helloMessage.protocolVersion.toString(16)} ` +
|
|
196
|
+
`whereas server protocolVersion is 0x${this.protocolVersion.toString(16)}`);
|
|
197
197
|
}
|
|
198
198
|
if (helloMessage.protocolVersion === 0xdeadbeef || helloMessage.protocolVersion < this.protocolVersion) {
|
|
199
199
|
// Note: 0xDEADBEEF is our special version number to simulate BadProtocolVersionUnsupported in tests
|
|
@@ -221,9 +221,7 @@ class ServerTCP_transport extends tcp_transport_1.TCP_transport {
|
|
|
221
221
|
else {
|
|
222
222
|
// invalid packet , expecting HEL
|
|
223
223
|
/* istanbul ignore next*/
|
|
224
|
-
|
|
225
|
-
debugLog(chalk.red("BadCommunicationError ") + "Expecting 'HEL' message to initiate communication");
|
|
226
|
-
}
|
|
224
|
+
doDebug && debugLog(chalk.red("BadCommunicationError ") + "Expecting 'HEL' message to initiate communication");
|
|
227
225
|
this._abortWithError(node_opcua_status_code_1.StatusCodes.BadCommunicationError, "Expecting 'HEL' message to initiate communication", callback);
|
|
228
226
|
}
|
|
229
227
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server_tcp_transport.js","sourceRoot":"","sources":["../../source/server_tcp_transport.ts"],"names":[],"mappings":";;;AAMA,+BAA+B;AAC/B,yDAA2C;AAE3C,iBAAiB;AACjB,0CAA0C;AAC1C,uEAAwD;AACxD,qEAA+D;AAC/D,mEAAiE;AAGjE,wBAAwB;AACxB,6DAA0D;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