node-opcua-transport 2.71.0 → 2.72.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 (37) hide show
  1. package/dist/source/AcknowledgeMessage.d.ts +27 -27
  2. package/dist/source/AcknowledgeMessage.js +78 -78
  3. package/dist/source/HelloMessage.d.ts +27 -27
  4. package/dist/source/HelloMessage.js +94 -94
  5. package/dist/source/TCPErrorMessage.d.ts +18 -18
  6. package/dist/source/TCPErrorMessage.js +46 -46
  7. package/dist/source/client_tcp_transport.d.ts +72 -72
  8. package/dist/source/client_tcp_transport.js +322 -322
  9. package/dist/source/index.d.ts +13 -13
  10. package/dist/source/index.js +29 -29
  11. package/dist/source/message_builder_base.d.ts +81 -81
  12. package/dist/source/message_builder_base.js +229 -229
  13. package/dist/source/server_tcp_transport.d.ts +44 -44
  14. package/dist/source/server_tcp_transport.js +228 -228
  15. package/dist/source/status_codes.d.ts +100 -100
  16. package/dist/source/status_codes.js +110 -110
  17. package/dist/source/tcp_transport.d.ts +119 -119
  18. package/dist/source/tcp_transport.js +386 -386
  19. package/dist/source/tools.d.ts +14 -14
  20. package/dist/source/tools.js +103 -103
  21. package/dist/source/utils.d.ts +3 -3
  22. package/dist/source/utils.js +9 -9
  23. package/dist/test-fixtures/fixture_full_tcp_packets.d.ts +21 -21
  24. package/dist/test-fixtures/fixture_full_tcp_packets.js +41 -41
  25. package/dist/test-fixtures/index.d.ts +1 -1
  26. package/dist/test-fixtures/index.js +17 -17
  27. package/dist/test_helpers/direct_transport.d.ts +18 -18
  28. package/dist/test_helpers/direct_transport.js +62 -62
  29. package/dist/test_helpers/fake_server.d.ts +19 -19
  30. package/dist/test_helpers/fake_server.js +54 -54
  31. package/dist/test_helpers/half_com_channel.d.ts +17 -17
  32. package/dist/test_helpers/half_com_channel.js +31 -31
  33. package/dist/test_helpers/index.d.ts +4 -4
  34. package/dist/test_helpers/index.js +20 -20
  35. package/dist/test_helpers/socket_transport.d.ts +10 -10
  36. package/dist/test_helpers/socket_transport.js +30 -30
  37. package/package.json +3 -3
@@ -1,229 +1,229 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ServerTCP_transport = void 0;
4
- const chalk = require("chalk");
5
- const node_opcua_assert_1 = require("node-opcua-assert");
6
- // opcua requires
7
- const debug = require("node-opcua-debug");
8
- const node_opcua_binary_stream_1 = require("node-opcua-binary-stream");
9
- const node_opcua_chunkmanager_1 = require("node-opcua-chunkmanager");
10
- const node_opcua_status_code_1 = require("node-opcua-status-code");
11
- // this package requires
12
- const AcknowledgeMessage_1 = require("./AcknowledgeMessage");
13
- const HelloMessage_1 = require("./HelloMessage");
14
- const tcp_transport_1 = require("./tcp_transport");
15
- const tools_1 = require("./tools");
16
- const utils_1 = require("./utils");
17
- const hexDump = debug.hexDump;
18
- const debugLog = debug.make_debugLog(__filename);
19
- const errorLog = debug.make_errorLog(__filename);
20
- const doDebug = debug.checkDebugFlag(__filename);
21
- function clamp_value(value, minVal, maxVal) {
22
- (0, node_opcua_assert_1.assert)(minVal < maxVal);
23
- if (value === 0) {
24
- return maxVal;
25
- }
26
- if (value < minVal) {
27
- return minVal;
28
- }
29
- /* istanbul ignore next*/
30
- if (value >= maxVal) {
31
- return maxVal;
32
- }
33
- return value;
34
- }
35
- const minimumBufferSize = 8192;
36
- /**
37
- * @class ServerTCP_transport
38
- * @extends TCP_transport
39
- * @constructor
40
- *
41
- */
42
- class ServerTCP_transport extends tcp_transport_1.TCP_transport {
43
- constructor() {
44
- super();
45
- this._aborted = 0;
46
- this._helloReceived = false;
47
- // before HEL/ACK
48
- this.maxChunkCount = 1;
49
- this.maxMessageSize = 4 * 1024;
50
- this.receiveBufferSize = 4 * 1024;
51
- }
52
- _write_chunk(messageChunk) {
53
- // istanbul ignore next
54
- if (this.sendBufferSize > 0 && messageChunk.length > this.sendBufferSize) {
55
- errorLog("write chunk exceed sendBufferSize messageChunk length = ", messageChunk.length, "sendBufferSize = ", this.sendBufferSize);
56
- }
57
- super._write_chunk(messageChunk);
58
- }
59
- /**
60
- * Initialize the server transport.
61
- *
62
- *
63
- * The ServerTCP_transport initialization process starts by waiting for the client to send a "HEL" message.
64
- *
65
- * The ServerTCP_transport replies with a "ACK" message and then start waiting for further messages of any size.
66
- *
67
- * The callback function received an error:
68
- * - if no message from the client is received within the ```self.timeout``` period,
69
- * - or, if the connection has dropped within the same interval.
70
- * - if the protocol version specified within the HEL message is invalid or is greater
71
- * than ```self.protocolVersion```
72
- *
73
- *
74
- */
75
- init(socket, callback) {
76
- if (debugLog) {
77
- debugLog(chalk.cyan("init socket"));
78
- }
79
- (0, node_opcua_assert_1.assert)(!this._socket, "init already called!");
80
- (0, node_opcua_assert_1.assert)(typeof callback === "function", "expecting a valid callback ");
81
- this._install_socket(socket);
82
- this._install_HEL_message_receiver(callback);
83
- }
84
- abortWithError(statusCode, extraErrorDescription, callback) {
85
- return this._abortWithError(statusCode, extraErrorDescription, callback);
86
- }
87
- _abortWithError(statusCode, extraErrorDescription, callback) {
88
- // When a fatal error occurs, the Server shall send an Error Message to the Client and
89
- // closes the TransportConnection gracefully.
90
- doDebug && debugLog(chalk.cyan("_abortWithError"));
91
- /* istanbul ignore next */
92
- if (this._aborted) {
93
- // already called
94
- return callback(new Error(statusCode.name));
95
- }
96
- this._aborted = 1;
97
- setTimeout(() => {
98
- // send the error message and close the connection
99
- this.sendErrorMessage(statusCode, statusCode.description);
100
- this.disconnect(() => {
101
- this._aborted = 2;
102
- callback(new Error(extraErrorDescription + " StatusCode = " + statusCode.name));
103
- });
104
- }, ServerTCP_transport.throttleTime);
105
- }
106
- _send_ACK_response(helloMessage) {
107
- (0, node_opcua_assert_1.assert)(helloMessage.receiveBufferSize >= minimumBufferSize);
108
- (0, node_opcua_assert_1.assert)(helloMessage.sendBufferSize >= minimumBufferSize);
109
- const minBufferSize = 8192;
110
- const maxBufferSize = 64 * 1024;
111
- const minMaxMessageSize = 128 * 1024;
112
- const defaultMaxMessageSize = 16 * 1024 * 1024;
113
- const maxMaxMessageSize = 128 * 1024 * 1024;
114
- const minMaxChunkCount = 1;
115
- const defaultMaxChunkCount = defaultMaxMessageSize / maxBufferSize;
116
- const maxMaxChunkCount = 9000;
117
- const receiveBufferSize = 32 * 1024;
118
- const sendBufferSize = 32 * 1024;
119
- if (!helloMessage.maxChunkCount && helloMessage.sendBufferSize) {
120
- helloMessage.maxChunkCount = helloMessage.maxMessageSize / helloMessage.sendBufferSize;
121
- }
122
- this.setLimits({
123
- receiveBufferSize: clamp_value(helloMessage.receiveBufferSize || receiveBufferSize, minBufferSize, maxBufferSize),
124
- sendBufferSize: clamp_value(helloMessage.sendBufferSize || sendBufferSize, minBufferSize, maxBufferSize),
125
- maxMessageSize: clamp_value(helloMessage.maxMessageSize || defaultMaxMessageSize, minMaxMessageSize, maxMaxMessageSize),
126
- maxChunkCount: clamp_value(helloMessage.maxChunkCount || defaultMaxChunkCount, minMaxChunkCount, maxMaxChunkCount)
127
- });
128
- // istanbul ignore next
129
- if (utils_1.doTraceHelloAck) {
130
- console.log(`received Hello \n${helloMessage.toString()}`);
131
- console.log("Client accepts only message of size => ", this.maxMessageSize);
132
- }
133
- debugLog("Client accepts only message of size => ", this.maxMessageSize);
134
- const acknowledgeMessage = new AcknowledgeMessage_1.AcknowledgeMessage({
135
- maxChunkCount: this.maxChunkCount,
136
- maxMessageSize: this.maxMessageSize,
137
- protocolVersion: this.protocolVersion,
138
- receiveBufferSize: this.receiveBufferSize,
139
- sendBufferSize: this.sendBufferSize
140
- });
141
- // istanbul ignore next
142
- if (utils_1.doTraceHelloAck) {
143
- console.log(`sending Ack \n${acknowledgeMessage.toString()}`);
144
- }
145
- const messageChunk = (0, tools_1.packTcpMessage)("ACK", acknowledgeMessage);
146
- /* istanbul ignore next*/
147
- if (doDebug) {
148
- (0, node_opcua_chunkmanager_1.verify_message_chunk)(messageChunk);
149
- debugLog("server send: " + chalk.yellow("ACK"));
150
- debugLog("server send: " + hexDump(messageChunk));
151
- debugLog("acknowledgeMessage=", acknowledgeMessage);
152
- }
153
- // send the ACK reply
154
- this.write(messageChunk);
155
- }
156
- _install_HEL_message_receiver(callback) {
157
- if (debugLog) {
158
- debugLog(chalk.cyan("_install_HEL_message_receiver "));
159
- }
160
- this._install_one_time_message_receiver((err, data) => {
161
- if (err) {
162
- this._abortWithError(node_opcua_status_code_1.StatusCodes.BadConnectionRejected, err.message, callback);
163
- }
164
- else {
165
- // handle the HEL message
166
- this._on_HEL_message(data, callback);
167
- }
168
- });
169
- }
170
- _on_HEL_message(data, callback) {
171
- if (debugLog) {
172
- debugLog(chalk.cyan("_on_HEL_message"));
173
- }
174
- (0, node_opcua_assert_1.assert)(!this._helloReceived);
175
- const stream = new node_opcua_binary_stream_1.BinaryStream(data);
176
- const msgType = data.slice(0, 3).toString("utf-8");
177
- /* istanbul ignore next*/
178
- if (doDebug) {
179
- debugLog("SERVER received " + chalk.yellow(msgType));
180
- debugLog("SERVER received " + hexDump(data));
181
- }
182
- if (msgType === "HEL") {
183
- try {
184
- (0, node_opcua_assert_1.assert)(data.length >= 24);
185
- const helloMessage = (0, tools_1.decodeMessage)(stream, HelloMessage_1.HelloMessage);
186
- (0, node_opcua_assert_1.assert)(isFinite(this.protocolVersion));
187
- // OPCUA Spec 1.03 part 6 - page 41
188
- // The Server shall always accept versions greater than what it supports.
189
- if (helloMessage.protocolVersion !== this.protocolVersion) {
190
- debugLog(`warning ! client sent helloMessage.protocolVersion = ` +
191
- ` 0x${helloMessage.protocolVersion.toString(16)} ` +
192
- `whereas server protocolVersion is 0x${this.protocolVersion.toString(16)}`);
193
- }
194
- if (helloMessage.protocolVersion === 0xdeadbeef || helloMessage.protocolVersion < this.protocolVersion) {
195
- // Note: 0xDEADBEEF is our special version number to simulate BadProtocolVersionUnsupported in tests
196
- // invalid protocol version requested by client
197
- return this._abortWithError(node_opcua_status_code_1.StatusCodes.BadProtocolVersionUnsupported, "Protocol Version Error" + this.protocolVersion, callback);
198
- }
199
- // OPCUA Spec 1.04 part 6 - page 45
200
- // UASC is designed to operate with different TransportProtocols that may have limited buffer
201
- // sizes. For this reason, OPC UA Secure Conversation will break OPC UA Messages into several
202
- // pieces (called ‘MessageChunks’) that are smaller than the buffer size allowed by the
203
- // TransportProtocol. UASC requires a TransportProtocol buffer size that is at least 8 192 bytes
204
- if (helloMessage.receiveBufferSize < minimumBufferSize || helloMessage.sendBufferSize < minimumBufferSize) {
205
- return this._abortWithError(node_opcua_status_code_1.StatusCodes.BadConnectionRejected, "Buffer size too small (should be at least " + minimumBufferSize, callback);
206
- }
207
- // the helloMessage shall only be received once.
208
- this._helloReceived = true;
209
- this._send_ACK_response(helloMessage);
210
- }
211
- catch (err) {
212
- // connection rejected because of malformed message
213
- return this._abortWithError(node_opcua_status_code_1.StatusCodes.BadConnectionRejected, err instanceof Error ? err.message : "", callback);
214
- }
215
- callback(); // no Error
216
- }
217
- else {
218
- // invalid packet , expecting HEL
219
- /* istanbul ignore next*/
220
- if (doDebug) {
221
- debugLog(chalk.red("BadCommunicationError ") + "Expecting 'HEL' message to initiate communication");
222
- }
223
- this._abortWithError(node_opcua_status_code_1.StatusCodes.BadCommunicationError, "Expecting 'HEL' message to initiate communication", callback);
224
- }
225
- }
226
- }
227
- exports.ServerTCP_transport = ServerTCP_transport;
228
- ServerTCP_transport.throttleTime = 1000;
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.ServerTCP_transport = void 0;
4
+ const chalk = require("chalk");
5
+ const node_opcua_assert_1 = require("node-opcua-assert");
6
+ // opcua requires
7
+ const debug = require("node-opcua-debug");
8
+ const node_opcua_binary_stream_1 = require("node-opcua-binary-stream");
9
+ const node_opcua_chunkmanager_1 = require("node-opcua-chunkmanager");
10
+ const node_opcua_status_code_1 = require("node-opcua-status-code");
11
+ // this package requires
12
+ const AcknowledgeMessage_1 = require("./AcknowledgeMessage");
13
+ const HelloMessage_1 = require("./HelloMessage");
14
+ const tcp_transport_1 = require("./tcp_transport");
15
+ const tools_1 = require("./tools");
16
+ const utils_1 = require("./utils");
17
+ const hexDump = debug.hexDump;
18
+ const debugLog = debug.make_debugLog(__filename);
19
+ const errorLog = debug.make_errorLog(__filename);
20
+ const doDebug = debug.checkDebugFlag(__filename);
21
+ function clamp_value(value, minVal, maxVal) {
22
+ (0, node_opcua_assert_1.assert)(minVal < maxVal);
23
+ if (value === 0) {
24
+ return maxVal;
25
+ }
26
+ if (value < minVal) {
27
+ return minVal;
28
+ }
29
+ /* istanbul ignore next*/
30
+ if (value >= maxVal) {
31
+ return maxVal;
32
+ }
33
+ return value;
34
+ }
35
+ const minimumBufferSize = 8192;
36
+ /**
37
+ * @class ServerTCP_transport
38
+ * @extends TCP_transport
39
+ * @constructor
40
+ *
41
+ */
42
+ class ServerTCP_transport extends tcp_transport_1.TCP_transport {
43
+ constructor() {
44
+ super();
45
+ this._aborted = 0;
46
+ this._helloReceived = false;
47
+ // before HEL/ACK
48
+ this.maxChunkCount = 1;
49
+ this.maxMessageSize = 4 * 1024;
50
+ this.receiveBufferSize = 4 * 1024;
51
+ }
52
+ _write_chunk(messageChunk) {
53
+ // istanbul ignore next
54
+ if (this.sendBufferSize > 0 && messageChunk.length > this.sendBufferSize) {
55
+ errorLog("write chunk exceed sendBufferSize messageChunk length = ", messageChunk.length, "sendBufferSize = ", this.sendBufferSize);
56
+ }
57
+ super._write_chunk(messageChunk);
58
+ }
59
+ /**
60
+ * Initialize the server transport.
61
+ *
62
+ *
63
+ * The ServerTCP_transport initialization process starts by waiting for the client to send a "HEL" message.
64
+ *
65
+ * The ServerTCP_transport replies with a "ACK" message and then start waiting for further messages of any size.
66
+ *
67
+ * The callback function received an error:
68
+ * - if no message from the client is received within the ```self.timeout``` period,
69
+ * - or, if the connection has dropped within the same interval.
70
+ * - if the protocol version specified within the HEL message is invalid or is greater
71
+ * than ```self.protocolVersion```
72
+ *
73
+ *
74
+ */
75
+ init(socket, callback) {
76
+ if (debugLog) {
77
+ debugLog(chalk.cyan("init socket"));
78
+ }
79
+ (0, node_opcua_assert_1.assert)(!this._socket, "init already called!");
80
+ (0, node_opcua_assert_1.assert)(typeof callback === "function", "expecting a valid callback ");
81
+ this._install_socket(socket);
82
+ this._install_HEL_message_receiver(callback);
83
+ }
84
+ abortWithError(statusCode, extraErrorDescription, callback) {
85
+ return this._abortWithError(statusCode, extraErrorDescription, callback);
86
+ }
87
+ _abortWithError(statusCode, extraErrorDescription, callback) {
88
+ // When a fatal error occurs, the Server shall send an Error Message to the Client and
89
+ // closes the TransportConnection gracefully.
90
+ doDebug && debugLog(chalk.cyan("_abortWithError"));
91
+ /* istanbul ignore next */
92
+ if (this._aborted) {
93
+ // already called
94
+ return callback(new Error(statusCode.name));
95
+ }
96
+ this._aborted = 1;
97
+ setTimeout(() => {
98
+ // send the error message and close the connection
99
+ this.sendErrorMessage(statusCode, statusCode.description);
100
+ this.disconnect(() => {
101
+ this._aborted = 2;
102
+ callback(new Error(extraErrorDescription + " StatusCode = " + statusCode.name));
103
+ });
104
+ }, ServerTCP_transport.throttleTime);
105
+ }
106
+ _send_ACK_response(helloMessage) {
107
+ (0, node_opcua_assert_1.assert)(helloMessage.receiveBufferSize >= minimumBufferSize);
108
+ (0, node_opcua_assert_1.assert)(helloMessage.sendBufferSize >= minimumBufferSize);
109
+ const minBufferSize = 8192;
110
+ const maxBufferSize = 64 * 1024;
111
+ const minMaxMessageSize = 128 * 1024;
112
+ const defaultMaxMessageSize = 16 * 1024 * 1024;
113
+ const maxMaxMessageSize = 128 * 1024 * 1024;
114
+ const minMaxChunkCount = 1;
115
+ const defaultMaxChunkCount = defaultMaxMessageSize / maxBufferSize;
116
+ const maxMaxChunkCount = 9000;
117
+ const receiveBufferSize = 32 * 1024;
118
+ const sendBufferSize = 32 * 1024;
119
+ if (!helloMessage.maxChunkCount && helloMessage.sendBufferSize) {
120
+ helloMessage.maxChunkCount = helloMessage.maxMessageSize / helloMessage.sendBufferSize;
121
+ }
122
+ this.setLimits({
123
+ receiveBufferSize: clamp_value(helloMessage.receiveBufferSize || receiveBufferSize, minBufferSize, maxBufferSize),
124
+ sendBufferSize: clamp_value(helloMessage.sendBufferSize || sendBufferSize, minBufferSize, maxBufferSize),
125
+ maxMessageSize: clamp_value(helloMessage.maxMessageSize || defaultMaxMessageSize, minMaxMessageSize, maxMaxMessageSize),
126
+ maxChunkCount: clamp_value(helloMessage.maxChunkCount || defaultMaxChunkCount, minMaxChunkCount, maxMaxChunkCount)
127
+ });
128
+ // istanbul ignore next
129
+ if (utils_1.doTraceHelloAck) {
130
+ console.log(`received Hello \n${helloMessage.toString()}`);
131
+ console.log("Client accepts only message of size => ", this.maxMessageSize);
132
+ }
133
+ debugLog("Client accepts only message of size => ", this.maxMessageSize);
134
+ const acknowledgeMessage = new AcknowledgeMessage_1.AcknowledgeMessage({
135
+ maxChunkCount: this.maxChunkCount,
136
+ maxMessageSize: this.maxMessageSize,
137
+ protocolVersion: this.protocolVersion,
138
+ receiveBufferSize: this.receiveBufferSize,
139
+ sendBufferSize: this.sendBufferSize
140
+ });
141
+ // istanbul ignore next
142
+ if (utils_1.doTraceHelloAck) {
143
+ console.log(`sending Ack \n${acknowledgeMessage.toString()}`);
144
+ }
145
+ const messageChunk = (0, tools_1.packTcpMessage)("ACK", acknowledgeMessage);
146
+ /* istanbul ignore next*/
147
+ if (doDebug) {
148
+ (0, node_opcua_chunkmanager_1.verify_message_chunk)(messageChunk);
149
+ debugLog("server send: " + chalk.yellow("ACK"));
150
+ debugLog("server send: " + hexDump(messageChunk));
151
+ debugLog("acknowledgeMessage=", acknowledgeMessage);
152
+ }
153
+ // send the ACK reply
154
+ this.write(messageChunk);
155
+ }
156
+ _install_HEL_message_receiver(callback) {
157
+ if (debugLog) {
158
+ debugLog(chalk.cyan("_install_HEL_message_receiver "));
159
+ }
160
+ this._install_one_time_message_receiver((err, data) => {
161
+ if (err) {
162
+ this._abortWithError(node_opcua_status_code_1.StatusCodes.BadConnectionRejected, err.message, callback);
163
+ }
164
+ else {
165
+ // handle the HEL message
166
+ this._on_HEL_message(data, callback);
167
+ }
168
+ });
169
+ }
170
+ _on_HEL_message(data, callback) {
171
+ if (debugLog) {
172
+ debugLog(chalk.cyan("_on_HEL_message"));
173
+ }
174
+ (0, node_opcua_assert_1.assert)(!this._helloReceived);
175
+ const stream = new node_opcua_binary_stream_1.BinaryStream(data);
176
+ const msgType = data.slice(0, 3).toString("utf-8");
177
+ /* istanbul ignore next*/
178
+ if (doDebug) {
179
+ debugLog("SERVER received " + chalk.yellow(msgType));
180
+ debugLog("SERVER received " + hexDump(data));
181
+ }
182
+ if (msgType === "HEL") {
183
+ try {
184
+ (0, node_opcua_assert_1.assert)(data.length >= 24);
185
+ const helloMessage = (0, tools_1.decodeMessage)(stream, HelloMessage_1.HelloMessage);
186
+ (0, node_opcua_assert_1.assert)(isFinite(this.protocolVersion));
187
+ // OPCUA Spec 1.03 part 6 - page 41
188
+ // The Server shall always accept versions greater than what it supports.
189
+ if (helloMessage.protocolVersion !== this.protocolVersion) {
190
+ debugLog(`warning ! client sent helloMessage.protocolVersion = ` +
191
+ ` 0x${helloMessage.protocolVersion.toString(16)} ` +
192
+ `whereas server protocolVersion is 0x${this.protocolVersion.toString(16)}`);
193
+ }
194
+ if (helloMessage.protocolVersion === 0xdeadbeef || helloMessage.protocolVersion < this.protocolVersion) {
195
+ // Note: 0xDEADBEEF is our special version number to simulate BadProtocolVersionUnsupported in tests
196
+ // invalid protocol version requested by client
197
+ return this._abortWithError(node_opcua_status_code_1.StatusCodes.BadProtocolVersionUnsupported, "Protocol Version Error" + this.protocolVersion, callback);
198
+ }
199
+ // OPCUA Spec 1.04 part 6 - page 45
200
+ // UASC is designed to operate with different TransportProtocols that may have limited buffer
201
+ // sizes. For this reason, OPC UA Secure Conversation will break OPC UA Messages into several
202
+ // pieces (called ‘MessageChunks’) that are smaller than the buffer size allowed by the
203
+ // TransportProtocol. UASC requires a TransportProtocol buffer size that is at least 8 192 bytes
204
+ if (helloMessage.receiveBufferSize < minimumBufferSize || helloMessage.sendBufferSize < minimumBufferSize) {
205
+ return this._abortWithError(node_opcua_status_code_1.StatusCodes.BadConnectionRejected, "Buffer size too small (should be at least " + minimumBufferSize, callback);
206
+ }
207
+ // the helloMessage shall only be received once.
208
+ this._helloReceived = true;
209
+ this._send_ACK_response(helloMessage);
210
+ }
211
+ catch (err) {
212
+ // connection rejected because of malformed message
213
+ return this._abortWithError(node_opcua_status_code_1.StatusCodes.BadConnectionRejected, err instanceof Error ? err.message : "", callback);
214
+ }
215
+ callback(); // no Error
216
+ }
217
+ else {
218
+ // invalid packet , expecting HEL
219
+ /* istanbul ignore next*/
220
+ if (doDebug) {
221
+ debugLog(chalk.red("BadCommunicationError ") + "Expecting 'HEL' message to initiate communication");
222
+ }
223
+ this._abortWithError(node_opcua_status_code_1.StatusCodes.BadCommunicationError, "Expecting 'HEL' message to initiate communication", callback);
224
+ }
225
+ }
226
+ }
227
+ exports.ServerTCP_transport = ServerTCP_transport;
228
+ ServerTCP_transport.throttleTime = 1000;
229
229
  //# sourceMappingURL=server_tcp_transport.js.map