node-opcua-transport 2.98.0 → 2.99.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/AcknowledgeMessage.d.ts +27 -0
- package/dist/source/AcknowledgeMessage.js +79 -0
- package/dist/source/AcknowledgeMessage.js.map +1 -0
- package/dist/source/HelloMessage.d.ts +27 -0
- package/dist/source/HelloMessage.js +95 -0
- package/dist/source/HelloMessage.js.map +1 -0
- package/dist/source/TCPErrorMessage.d.ts +18 -0
- package/dist/source/TCPErrorMessage.js +47 -0
- package/dist/source/TCPErrorMessage.js.map +1 -0
- package/dist/source/client_tcp_transport.d.ts +87 -0
- package/dist/source/client_tcp_transport.js +335 -0
- package/dist/source/client_tcp_transport.js.map +1 -0
- package/dist/source/index.d.ts +13 -0
- package/dist/source/index.js +30 -0
- package/dist/source/index.js.map +1 -0
- package/dist/source/message_builder_base.d.ts +112 -0
- package/dist/source/message_builder_base.js +245 -0
- package/dist/source/message_builder_base.js.map +1 -0
- package/dist/source/server_tcp_transport.d.ts +44 -0
- package/dist/source/server_tcp_transport.js +233 -0
- package/dist/source/server_tcp_transport.js.map +1 -0
- package/dist/source/status_codes.d.ts +100 -0
- package/dist/source/status_codes.js +111 -0
- package/dist/source/status_codes.js.map +1 -0
- package/dist/source/tcp_transport.d.ts +136 -0
- package/dist/source/tcp_transport.js +380 -0
- package/dist/source/tcp_transport.js.map +1 -0
- package/dist/source/tools.d.ts +14 -0
- package/dist/source/tools.js +104 -0
- package/dist/source/tools.js.map +1 -0
- package/dist/source/utils.d.ts +3 -0
- package/dist/source/utils.js +10 -0
- package/dist/source/utils.js.map +1 -0
- package/dist/test-fixtures/fixture_full_tcp_packets.d.ts +21 -0
- package/dist/test-fixtures/fixture_full_tcp_packets.js +413 -0
- package/dist/test-fixtures/fixture_full_tcp_packets.js.map +1 -0
- package/dist/test-fixtures/index.d.ts +1 -0
- package/dist/test-fixtures/index.js +18 -0
- package/dist/test-fixtures/index.js.map +1 -0
- package/dist/test_helpers/direct_transport.d.ts +18 -0
- package/{test_helpers/direct_transport.ts → dist/test_helpers/direct_transport.js} +21 -34
- package/dist/test_helpers/direct_transport.js.map +1 -0
- package/dist/test_helpers/fake_server.d.ts +19 -0
- package/{test_helpers/fake_server.ts → dist/test_helpers/fake_server.js} +20 -32
- package/dist/test_helpers/fake_server.js.map +1 -0
- package/dist/test_helpers/half_com_channel.d.ts +17 -0
- package/dist/test_helpers/half_com_channel.js +32 -0
- package/dist/test_helpers/half_com_channel.js.map +1 -0
- package/dist/test_helpers/index.js +21 -0
- package/dist/test_helpers/index.js.map +1 -0
- package/dist/test_helpers/socket_transport.d.ts +10 -0
- package/dist/test_helpers/socket_transport.js +31 -0
- package/dist/test_helpers/socket_transport.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +18 -14
- package/test_helpers/half_com_channel.ts +0 -41
- package/test_helpers/socket_transport.ts +0 -33
- /package/{test_helpers/index.ts → dist/test_helpers/index.d.ts} +0 -0
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.StatusCodes2 = void 0;
|
|
4
|
+
const node_opcua_status_code_1 = require("node-opcua-status-code");
|
|
5
|
+
exports.StatusCodes2 = {
|
|
6
|
+
/**
|
|
7
|
+
* The Server cannot process the request because it is too busy.
|
|
8
|
+
*
|
|
9
|
+
* It is up to the Server to determine when it needs to return this Message.
|
|
10
|
+
*
|
|
11
|
+
* A Server can control the how frequently a Client reconnects by waiting to return this error.
|
|
12
|
+
*/
|
|
13
|
+
BadTcpServerTooBusy: node_opcua_status_code_1.StatusCodes.BadTcpServerTooBusy,
|
|
14
|
+
/**
|
|
15
|
+
* The type of the Message specified in the header invalid.
|
|
16
|
+
* Each Message starts with a 4-byte sequence of ASCII values that identifies the Message type.
|
|
17
|
+
* The Server returns this error if the Message type is not accepted.
|
|
18
|
+
* Some of the Message types are defined by the SecureChannel layer.
|
|
19
|
+
*/
|
|
20
|
+
BadTcpMessageTypeInvalid: node_opcua_status_code_1.StatusCodes.BadTcpMessageTypeInvalid,
|
|
21
|
+
/**
|
|
22
|
+
* The SecureChannelId and/or TokenId are not currently in use.
|
|
23
|
+
* This error is reported by the SecureChannel layer.
|
|
24
|
+
*/
|
|
25
|
+
BadTcpSecureChannelUnknown: node_opcua_status_code_1.StatusCodes.BadTcpSecureChannelUnknown,
|
|
26
|
+
/**
|
|
27
|
+
* The size of the Message specified in the header is too large.
|
|
28
|
+
* The Server returns this error if the Message size exceeds its maximum buffer size
|
|
29
|
+
* or the receive buffer size negotiated during the Hello/Acknowledge exchange.
|
|
30
|
+
*/
|
|
31
|
+
BadTcpMessageTooLarge: node_opcua_status_code_1.StatusCodes.BadTcpMessageTooLarge,
|
|
32
|
+
/**
|
|
33
|
+
* A timeout occurred while accessing a resource.
|
|
34
|
+
* It is up to the Server to determine when a timeout occurs.
|
|
35
|
+
*/
|
|
36
|
+
BadTimeout: node_opcua_status_code_1.StatusCodes.BadTimeout,
|
|
37
|
+
/**
|
|
38
|
+
* There are not enough resources to process the request.
|
|
39
|
+
* The Server returns this error when it runs out of memory or encounters similar resource problems.
|
|
40
|
+
* A Server can control the how frequently a Client reconnects by waiting to return this error.
|
|
41
|
+
*/
|
|
42
|
+
BadTcpNotEnoughResources: node_opcua_status_code_1.StatusCodes.BadTcpNotEnoughResources,
|
|
43
|
+
/**
|
|
44
|
+
* An internal error occurred.
|
|
45
|
+
* This should only be returned if an unexpected configuration or programming error occurs.
|
|
46
|
+
*/
|
|
47
|
+
BadTcpInternalError: node_opcua_status_code_1.StatusCodes.BadTcpInternalError,
|
|
48
|
+
/**
|
|
49
|
+
* The Server does not recognize the EndpointUrl specified.
|
|
50
|
+
*/
|
|
51
|
+
BadTcpEndpointUrlInvalid: node_opcua_status_code_1.StatusCodes.BadTcpEndpointUrlInvalid,
|
|
52
|
+
/**
|
|
53
|
+
* The Message was rejected because it could not be verified.
|
|
54
|
+
*/
|
|
55
|
+
BadSecurityChecksFailed: node_opcua_status_code_1.StatusCodes.BadSecurityChecksFailed,
|
|
56
|
+
/**
|
|
57
|
+
* The request could not be sent because of a network interruption.
|
|
58
|
+
*/
|
|
59
|
+
BadRequestInterrupted: node_opcua_status_code_1.StatusCodes.BadRequestInterrupted,
|
|
60
|
+
/**
|
|
61
|
+
* Timeout occurred while processing the request.
|
|
62
|
+
*/
|
|
63
|
+
BadRequestTimeout: node_opcua_status_code_1.StatusCodes.BadRequestTimeout,
|
|
64
|
+
/**
|
|
65
|
+
* The secure channel has been closed.
|
|
66
|
+
*/
|
|
67
|
+
BadSecureChannelClosed: node_opcua_status_code_1.StatusCodes.BadSecureChannelClosed,
|
|
68
|
+
/**
|
|
69
|
+
* The SecurityToken has expired or is not recognized. BadSecureChannelTokenUnknown
|
|
70
|
+
*/
|
|
71
|
+
BadSecureChannelTokenUnknown: node_opcua_status_code_1.StatusCodes.BadSecureChannelTokenUnknown,
|
|
72
|
+
/**
|
|
73
|
+
* The sender Certificate is not trusted by the receiver.
|
|
74
|
+
*/
|
|
75
|
+
BadCertificateUntrusted: node_opcua_status_code_1.StatusCodes.BadCertificateUntrusted,
|
|
76
|
+
/**
|
|
77
|
+
* The sender Certificate has expired or is not yet valid.
|
|
78
|
+
*/
|
|
79
|
+
BadCertificateTimeInvalid: node_opcua_status_code_1.StatusCodes.BadCertificateTimeInvalid,
|
|
80
|
+
/**
|
|
81
|
+
* The issuer for the sender Certificate has expired or is not yet valid.
|
|
82
|
+
*/
|
|
83
|
+
BadCertificateIssuerTimeInvalid: node_opcua_status_code_1.StatusCodes.BadCertificateIssuerTimeInvalid,
|
|
84
|
+
/**
|
|
85
|
+
* The sender’s Certificate may not be used for establishing a secure channel.
|
|
86
|
+
*/
|
|
87
|
+
BadCertificateUseNotAllowed: node_opcua_status_code_1.StatusCodes.BadCertificateUseNotAllowed,
|
|
88
|
+
/**
|
|
89
|
+
* The issuer Certificate may not be used as a Certificate Authority.
|
|
90
|
+
*/
|
|
91
|
+
BadCertificateIssuerUseNotAllowed: node_opcua_status_code_1.StatusCodes.BadCertificateIssuerUseNotAllowed,
|
|
92
|
+
/**
|
|
93
|
+
* Could not verify the revocation status of the sender’s Certificate.
|
|
94
|
+
*/
|
|
95
|
+
BadCertificateRevocationUnknown: node_opcua_status_code_1.StatusCodes.BadCertificateRevocationUnknown,
|
|
96
|
+
/**
|
|
97
|
+
* Could not verify the revocation status of the issuer Certificate.
|
|
98
|
+
*/
|
|
99
|
+
BadCertificateIssuerRevocationUnknown: node_opcua_status_code_1.StatusCodes.BadCertificateIssuerRevocationUnknown,
|
|
100
|
+
/**
|
|
101
|
+
* The sender Certificate has been revoked by the issuer.
|
|
102
|
+
*/
|
|
103
|
+
BadCertificateRevoked: node_opcua_status_code_1.StatusCodes.BadCertificateRevoked
|
|
104
|
+
/**The issuer Certificate has been revoked by its issuer.
|
|
105
|
+
*/
|
|
106
|
+
// todo BadIssuerCertificateRevoked: StatusCodes.BadIssuerCertificateRevoked,
|
|
107
|
+
/** The receiver Certificate thumbprint is not recognized by the receiver.
|
|
108
|
+
*/
|
|
109
|
+
// todo .. BadCertificateUnknown: StatusCodes.BadCertificateUnknown
|
|
110
|
+
};
|
|
111
|
+
//# sourceMappingURL=status_codes.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"status_codes.js","sourceRoot":"","sources":["../../source/status_codes.ts"],"names":[],"mappings":";;;AAAA,mEAAqD;AAExC,QAAA,YAAY,GAAG;IACxB;;;;;;OAMG;IACH,mBAAmB,EAAE,oCAAW,CAAC,mBAAmB;IACpD;;;;;OAKG;IACH,wBAAwB,EAAE,oCAAW,CAAC,wBAAwB;IAC9D;;;OAGG;IACH,0BAA0B,EAAE,oCAAW,CAAC,0BAA0B;IAClE;;;;OAIG;IACH,qBAAqB,EAAE,oCAAW,CAAC,qBAAqB;IAExD;;;OAGG;IACH,UAAU,EAAE,oCAAW,CAAC,UAAU;IAClC;;;;OAIG;IACH,wBAAwB,EAAE,oCAAW,CAAC,wBAAwB;IAC9D;;;OAGG;IACH,mBAAmB,EAAE,oCAAW,CAAC,mBAAmB;IACpD;;OAEG;IACH,wBAAwB,EAAE,oCAAW,CAAC,wBAAwB;IAC9D;;OAEG;IACH,uBAAuB,EAAE,oCAAW,CAAC,uBAAuB;IAC5D;;OAEG;IACH,qBAAqB,EAAE,oCAAW,CAAC,qBAAqB;IACxD;;OAEG;IACH,iBAAiB,EAAE,oCAAW,CAAC,iBAAiB;IAChD;;OAEG;IACH,sBAAsB,EAAE,oCAAW,CAAC,sBAAsB;IAC1D;;OAEG;IACH,4BAA4B,EAAE,oCAAW,CAAC,4BAA4B;IACtE;;OAEG;IACH,uBAAuB,EAAE,oCAAW,CAAC,uBAAuB;IAC5D;;OAEG;IACH,yBAAyB,EAAE,oCAAW,CAAC,yBAAyB;IAChE;;OAEG;IACH,+BAA+B,EAAE,oCAAW,CAAC,+BAA+B;IAC5E;;OAEG;IACH,2BAA2B,EAAE,oCAAW,CAAC,2BAA2B;IACpE;;OAEG;IACH,iCAAiC,EAAE,oCAAW,CAAC,iCAAiC;IAChF;;OAEG;IACH,+BAA+B,EAAE,oCAAW,CAAC,+BAA+B;IAC5E;;OAEG;IACH,qCAAqC,EAAE,oCAAW,CAAC,qCAAqC;IACxF;;OAEG;IACH,qBAAqB,EAAE,oCAAW,CAAC,qBAAqB;IACxD;OACG;IACH,8EAA8E;IAC9E;OACG;IACH,mEAAmE;CACtE,CAAC"}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/// <reference types="node" />
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-transport
|
|
6
|
+
*/
|
|
7
|
+
import { EventEmitter } from "events";
|
|
8
|
+
import { Socket } from "net";
|
|
9
|
+
import { ErrorCallback, CallbackWithData, StatusCode } from "node-opcua-status-code";
|
|
10
|
+
export interface MockSocket {
|
|
11
|
+
invalid?: boolean;
|
|
12
|
+
[key: string]: any;
|
|
13
|
+
destroy(): void;
|
|
14
|
+
end(): void;
|
|
15
|
+
}
|
|
16
|
+
export declare function setFakeTransport(mockSocket: MockSocket): void;
|
|
17
|
+
export declare function getFakeTransport(): any;
|
|
18
|
+
export interface TCP_transport {
|
|
19
|
+
/**
|
|
20
|
+
* notify the observers that a message chunk has been received
|
|
21
|
+
* @event chunk
|
|
22
|
+
* @param message_chunk the message chunk
|
|
23
|
+
*/
|
|
24
|
+
on(eventName: "chunk", eventHandler: (messageChunk: Buffer) => void): this;
|
|
25
|
+
/**
|
|
26
|
+
* notify the observers that the transport layer has been disconnected.
|
|
27
|
+
* @event socket_closed
|
|
28
|
+
* @param err the Error object or null
|
|
29
|
+
*/
|
|
30
|
+
on(eventName: "socket_closed", eventHandler: (err: Error | null) => void): this;
|
|
31
|
+
/**
|
|
32
|
+
* notify the observers that the transport layer has been disconnected.
|
|
33
|
+
* @event close
|
|
34
|
+
*/
|
|
35
|
+
on(eventName: "close", eventHandler: (err: Error | null) => void): this;
|
|
36
|
+
once(eventName: "chunk", eventHandler: (messageChunk: Buffer) => void): this;
|
|
37
|
+
once(eventName: "socket_closed", eventHandler: (err: Error | null) => void): this;
|
|
38
|
+
once(eventName: "close", eventHandler: (err: Error | null) => void): this;
|
|
39
|
+
emit(eventName: "socket_closed", err?: Error | null): boolean;
|
|
40
|
+
emit(eventName: "close", err?: Error | null): boolean;
|
|
41
|
+
emit(eventName: "chunk", messageChunk: Buffer): boolean;
|
|
42
|
+
}
|
|
43
|
+
export declare class TCP_transport extends EventEmitter {
|
|
44
|
+
private static registry;
|
|
45
|
+
/**
|
|
46
|
+
* indicates the version number of the OPCUA protocol used
|
|
47
|
+
* @default 0
|
|
48
|
+
*/
|
|
49
|
+
protocolVersion: number;
|
|
50
|
+
maxMessageSize: number;
|
|
51
|
+
maxChunkCount: number;
|
|
52
|
+
sendBufferSize: number;
|
|
53
|
+
receiveBufferSize: number;
|
|
54
|
+
bytesWritten: number;
|
|
55
|
+
bytesRead: number;
|
|
56
|
+
chunkWrittenCount: number;
|
|
57
|
+
chunkReadCount: number;
|
|
58
|
+
name: string;
|
|
59
|
+
_socket: Socket | null;
|
|
60
|
+
/**
|
|
61
|
+
* the size of the header in bytes
|
|
62
|
+
* @default 8
|
|
63
|
+
*/
|
|
64
|
+
private readonly headerSize;
|
|
65
|
+
private _disconnecting;
|
|
66
|
+
private _timerId;
|
|
67
|
+
private _onSocketClosedHasBeenCalled;
|
|
68
|
+
private _onSocketEndedHasBeenCalled;
|
|
69
|
+
private _theCallback?;
|
|
70
|
+
private _on_error_during_one_time_message_receiver;
|
|
71
|
+
private packetAssembler?;
|
|
72
|
+
private _timeout;
|
|
73
|
+
constructor();
|
|
74
|
+
setLimits({ receiveBufferSize, sendBufferSize, maxMessageSize, maxChunkCount }: {
|
|
75
|
+
receiveBufferSize: number;
|
|
76
|
+
sendBufferSize: number;
|
|
77
|
+
maxMessageSize: number;
|
|
78
|
+
maxChunkCount: number;
|
|
79
|
+
}): void;
|
|
80
|
+
get timeout(): number;
|
|
81
|
+
set timeout(value: number);
|
|
82
|
+
dispose(): void;
|
|
83
|
+
/**
|
|
84
|
+
* write the message_chunk on the socket.
|
|
85
|
+
* @method write
|
|
86
|
+
* @param messageChunk
|
|
87
|
+
*/
|
|
88
|
+
write(messageChunk: Buffer, callback?: (err?: Error) => void | undefined): void;
|
|
89
|
+
get isDisconnecting(): boolean;
|
|
90
|
+
/**
|
|
91
|
+
* disconnect the TCP layer and close the underlying socket.
|
|
92
|
+
* The ```"close"``` event will be emitted to the observers with err=null.
|
|
93
|
+
*
|
|
94
|
+
* @method disconnect
|
|
95
|
+
* @async
|
|
96
|
+
* @param callback
|
|
97
|
+
*/
|
|
98
|
+
disconnect(callback: ErrorCallback): void;
|
|
99
|
+
isValid(): boolean;
|
|
100
|
+
protected _write_chunk(messageChunk: Buffer, callback?: (err?: Error) => void | undefined): void;
|
|
101
|
+
protected on_socket_ended(err: Error | null): void;
|
|
102
|
+
protected _install_packetAssembler(): void;
|
|
103
|
+
/**
|
|
104
|
+
* @method _install_socket
|
|
105
|
+
* @param socket {Socket}
|
|
106
|
+
* @protected
|
|
107
|
+
*/
|
|
108
|
+
protected _install_socket(socket: Socket): void;
|
|
109
|
+
sendErrorMessage(statusCode: StatusCode, extraErrorDescription: string | null): void;
|
|
110
|
+
prematureTerminate(err: Error, statusCode: StatusCode): void;
|
|
111
|
+
/**
|
|
112
|
+
* @method _install_one_time_message_receiver
|
|
113
|
+
*
|
|
114
|
+
* install a one time message receiver callback
|
|
115
|
+
*
|
|
116
|
+
* Rules:
|
|
117
|
+
* * TCP_transport will not emit the ```message``` event, while the "one time message receiver" is in operation.
|
|
118
|
+
* * the TCP_transport will wait for the next complete message chunk and call the provided callback func
|
|
119
|
+
* ```callback(null,messageChunk);```
|
|
120
|
+
*
|
|
121
|
+
* if a messageChunk is not received within ```TCP_transport.timeout``` or if the underlying socket reports
|
|
122
|
+
* an error, the callback function will be called with an Error.
|
|
123
|
+
*
|
|
124
|
+
*/
|
|
125
|
+
protected _install_one_time_message_receiver(callback: CallbackWithData): void;
|
|
126
|
+
private _fulfill_pending_promises;
|
|
127
|
+
private _on_message_chunk_received;
|
|
128
|
+
private _cleanup_timers;
|
|
129
|
+
private _start_one_time_message_receiver;
|
|
130
|
+
private on_socket_closed;
|
|
131
|
+
private _on_socket_data;
|
|
132
|
+
private _on_socket_close;
|
|
133
|
+
private _on_socket_ended_message;
|
|
134
|
+
private _on_socket_end;
|
|
135
|
+
private _on_socket_error;
|
|
136
|
+
}
|
|
@@ -0,0 +1,380 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TCP_transport = exports.getFakeTransport = exports.setFakeTransport = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* @module node-opcua-transport
|
|
6
|
+
*/
|
|
7
|
+
const events_1 = require("events");
|
|
8
|
+
const chalk = require("chalk");
|
|
9
|
+
const node_opcua_assert_1 = require("node-opcua-assert");
|
|
10
|
+
const node_opcua_debug_1 = require("node-opcua-debug");
|
|
11
|
+
const node_opcua_object_registry_1 = require("node-opcua-object-registry");
|
|
12
|
+
const node_opcua_packet_assembler_1 = require("node-opcua-packet-assembler");
|
|
13
|
+
const status_codes_1 = require("./status_codes");
|
|
14
|
+
const message_builder_base_1 = require("./message_builder_base");
|
|
15
|
+
const utils_1 = require("./utils");
|
|
16
|
+
const TCPErrorMessage_1 = require("./TCPErrorMessage");
|
|
17
|
+
const tools_1 = require("./tools");
|
|
18
|
+
const debugLog = (0, node_opcua_debug_1.make_debugLog)(__filename);
|
|
19
|
+
const doDebug = (0, node_opcua_debug_1.checkDebugFlag)(__filename);
|
|
20
|
+
const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
|
|
21
|
+
const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
|
|
22
|
+
let fakeSocket = {
|
|
23
|
+
invalid: true,
|
|
24
|
+
destroy() {
|
|
25
|
+
errorLog("MockSocket.destroy");
|
|
26
|
+
},
|
|
27
|
+
end() {
|
|
28
|
+
errorLog("MockSocket.end");
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
function setFakeTransport(mockSocket) {
|
|
32
|
+
fakeSocket = mockSocket;
|
|
33
|
+
}
|
|
34
|
+
exports.setFakeTransport = setFakeTransport;
|
|
35
|
+
function getFakeTransport() {
|
|
36
|
+
if (fakeSocket.invalid) {
|
|
37
|
+
throw new Error("getFakeTransport: setFakeTransport must be called first - BadProtocolVersionUnsupported");
|
|
38
|
+
}
|
|
39
|
+
return fakeSocket;
|
|
40
|
+
}
|
|
41
|
+
exports.getFakeTransport = getFakeTransport;
|
|
42
|
+
let counter = 0;
|
|
43
|
+
// tslint:disable:class-name
|
|
44
|
+
class TCP_transport extends events_1.EventEmitter {
|
|
45
|
+
constructor() {
|
|
46
|
+
super();
|
|
47
|
+
this.name = this.constructor.name + counter;
|
|
48
|
+
counter += 1;
|
|
49
|
+
this._timerId = null;
|
|
50
|
+
this._timeout = 30000; // 30 seconds timeout
|
|
51
|
+
this._socket = null;
|
|
52
|
+
this.headerSize = 8;
|
|
53
|
+
this.maxMessageSize = 0;
|
|
54
|
+
this.maxChunkCount = 0;
|
|
55
|
+
this.receiveBufferSize = 0;
|
|
56
|
+
this.sendBufferSize = 0;
|
|
57
|
+
this.protocolVersion = 0;
|
|
58
|
+
this._disconnecting = false;
|
|
59
|
+
this.bytesWritten = 0;
|
|
60
|
+
this.bytesRead = 0;
|
|
61
|
+
this._theCallback = undefined;
|
|
62
|
+
this.chunkWrittenCount = 0;
|
|
63
|
+
this.chunkReadCount = 0;
|
|
64
|
+
this._onSocketClosedHasBeenCalled = false;
|
|
65
|
+
this._onSocketEndedHasBeenCalled = false;
|
|
66
|
+
TCP_transport.registry.register(this);
|
|
67
|
+
}
|
|
68
|
+
setLimits({ receiveBufferSize, sendBufferSize, maxMessageSize, maxChunkCount }) {
|
|
69
|
+
this.receiveBufferSize = receiveBufferSize;
|
|
70
|
+
this.sendBufferSize = sendBufferSize;
|
|
71
|
+
this.maxMessageSize = maxMessageSize;
|
|
72
|
+
this.maxChunkCount = maxChunkCount;
|
|
73
|
+
if (maxMessageSize / sendBufferSize > maxChunkCount || maxMessageSize / receiveBufferSize > maxChunkCount) {
|
|
74
|
+
warningLog(`Warning : maxMessageSize / sendBufferSize ${maxMessageSize / sendBufferSize}> maxChunkCount ${maxChunkCount}
|
|
75
|
+
|| maxMessageSize / receiveBufferSize ${maxMessageSize / receiveBufferSize} < maxChunkCount `);
|
|
76
|
+
}
|
|
77
|
+
// reinstall packetAssembler with correct limits
|
|
78
|
+
this._install_packetAssembler();
|
|
79
|
+
}
|
|
80
|
+
get timeout() {
|
|
81
|
+
return this._timeout;
|
|
82
|
+
}
|
|
83
|
+
set timeout(value) {
|
|
84
|
+
debugLog("Setting socket " + this.name + " timeout = ", value);
|
|
85
|
+
this._timeout = value;
|
|
86
|
+
}
|
|
87
|
+
dispose() {
|
|
88
|
+
this._cleanup_timers();
|
|
89
|
+
(0, node_opcua_assert_1.assert)(!this._timerId);
|
|
90
|
+
if (this._socket) {
|
|
91
|
+
this._socket.destroy();
|
|
92
|
+
this._socket.removeAllListeners();
|
|
93
|
+
this._socket = null;
|
|
94
|
+
}
|
|
95
|
+
TCP_transport.registry.unregister(this);
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* write the message_chunk on the socket.
|
|
99
|
+
* @method write
|
|
100
|
+
* @param messageChunk
|
|
101
|
+
*/
|
|
102
|
+
write(messageChunk, callback) {
|
|
103
|
+
const header = (0, message_builder_base_1.readRawMessageHeader)(messageChunk);
|
|
104
|
+
(0, node_opcua_assert_1.assert)(header.length === messageChunk.length);
|
|
105
|
+
const c = header.messageHeader.isFinal;
|
|
106
|
+
(0, node_opcua_assert_1.assert)(c === "F" || c === "C" || c === "A");
|
|
107
|
+
this._write_chunk(messageChunk, (err) => {
|
|
108
|
+
callback && callback(err);
|
|
109
|
+
});
|
|
110
|
+
}
|
|
111
|
+
get isDisconnecting() {
|
|
112
|
+
return this._disconnecting;
|
|
113
|
+
}
|
|
114
|
+
/**
|
|
115
|
+
* disconnect the TCP layer and close the underlying socket.
|
|
116
|
+
* The ```"close"``` event will be emitted to the observers with err=null.
|
|
117
|
+
*
|
|
118
|
+
* @method disconnect
|
|
119
|
+
* @async
|
|
120
|
+
* @param callback
|
|
121
|
+
*/
|
|
122
|
+
disconnect(callback) {
|
|
123
|
+
(0, node_opcua_assert_1.assert)(typeof callback === "function", "expecting a callback function, but got " + callback);
|
|
124
|
+
if (this._disconnecting) {
|
|
125
|
+
callback();
|
|
126
|
+
return;
|
|
127
|
+
}
|
|
128
|
+
(0, node_opcua_assert_1.assert)(!this._disconnecting, "TCP Transport has already been disconnected");
|
|
129
|
+
this._disconnecting = true;
|
|
130
|
+
// xx assert(!this._theCallback,
|
|
131
|
+
// "disconnect shall not be called while the 'one time message receiver' is in operation");
|
|
132
|
+
this._cleanup_timers();
|
|
133
|
+
if (this._socket) {
|
|
134
|
+
this._socket.end();
|
|
135
|
+
this._socket && this._socket.destroy();
|
|
136
|
+
// xx this._socket.removeAllListeners();
|
|
137
|
+
this._socket = null;
|
|
138
|
+
}
|
|
139
|
+
this.on_socket_ended(null);
|
|
140
|
+
setImmediate(() => {
|
|
141
|
+
callback();
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
isValid() {
|
|
145
|
+
return this._socket !== null && !this._socket.destroyed && !this._disconnecting;
|
|
146
|
+
}
|
|
147
|
+
_write_chunk(messageChunk, callback) {
|
|
148
|
+
if (this._socket !== null) {
|
|
149
|
+
this.bytesWritten += messageChunk.length;
|
|
150
|
+
this.chunkWrittenCount++;
|
|
151
|
+
this._socket.write(messageChunk, callback);
|
|
152
|
+
}
|
|
153
|
+
else {
|
|
154
|
+
if (callback) {
|
|
155
|
+
callback();
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
on_socket_ended(err) {
|
|
160
|
+
if (!this._onSocketEndedHasBeenCalled) {
|
|
161
|
+
this._onSocketEndedHasBeenCalled = true; // we don't want to send close event twice ...
|
|
162
|
+
this.emit("close", err || null);
|
|
163
|
+
}
|
|
164
|
+
else {
|
|
165
|
+
debugLog("on_socket_ended has already been called");
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
_install_packetAssembler() {
|
|
169
|
+
if (this.packetAssembler) {
|
|
170
|
+
this.packetAssembler.removeAllListeners();
|
|
171
|
+
this.packetAssembler = undefined;
|
|
172
|
+
}
|
|
173
|
+
// install packet assembler ...
|
|
174
|
+
this.packetAssembler = new node_opcua_packet_assembler_1.PacketAssembler({
|
|
175
|
+
readChunkFunc: message_builder_base_1.readRawMessageHeader,
|
|
176
|
+
minimumSizeInBytes: this.headerSize,
|
|
177
|
+
maxChunkSize: this.receiveBufferSize //Math.max(this.receiveBufferSize, this.sendBufferSize)
|
|
178
|
+
});
|
|
179
|
+
this.packetAssembler.on("chunk", (chunk) => this._on_message_chunk_received(chunk));
|
|
180
|
+
this.packetAssembler.on("error", (err, code) => {
|
|
181
|
+
let statusCode = status_codes_1.StatusCodes2.BadTcpMessageTooLarge;
|
|
182
|
+
switch (code) {
|
|
183
|
+
case node_opcua_packet_assembler_1.PacketAssemblerErrorCode.ChunkSizeExceeded:
|
|
184
|
+
statusCode = status_codes_1.StatusCodes2.BadTcpMessageTooLarge;
|
|
185
|
+
break;
|
|
186
|
+
default:
|
|
187
|
+
statusCode = status_codes_1.StatusCodes2.BadTcpInternalError;
|
|
188
|
+
}
|
|
189
|
+
this.sendErrorMessage(statusCode, err.message);
|
|
190
|
+
this.prematureTerminate(new Error("Packet Assembler : " + err.message), statusCode);
|
|
191
|
+
});
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* @method _install_socket
|
|
195
|
+
* @param socket {Socket}
|
|
196
|
+
* @protected
|
|
197
|
+
*/
|
|
198
|
+
_install_socket(socket) {
|
|
199
|
+
(0, node_opcua_assert_1.assert)(socket);
|
|
200
|
+
this._socket = socket;
|
|
201
|
+
if (doDebug) {
|
|
202
|
+
debugLog(" TCP_transport#_install_socket ", this.name);
|
|
203
|
+
}
|
|
204
|
+
this._install_packetAssembler();
|
|
205
|
+
this._socket
|
|
206
|
+
.on("data", (data) => this._on_socket_data(data))
|
|
207
|
+
.on("close", (hadError) => this._on_socket_close(hadError))
|
|
208
|
+
.on("end", (err) => this._on_socket_end(err))
|
|
209
|
+
.on("error", (err) => this._on_socket_error(err));
|
|
210
|
+
// set socket timeout
|
|
211
|
+
debugLog(" TCP_transport#install => setting " + this.name + " _socket.setTimeout to ", this.timeout);
|
|
212
|
+
// let use a large timeout here to make sure that we not conflict with our internal timeout
|
|
213
|
+
this._socket.setTimeout(this.timeout + 2000, () => {
|
|
214
|
+
debugLog(` _socket ${this.name} has timed out (timeout = ${this.timeout})`);
|
|
215
|
+
this.prematureTerminate(new Error("socket timeout : timeout=" + this.timeout), status_codes_1.StatusCodes2.BadTimeout);
|
|
216
|
+
});
|
|
217
|
+
}
|
|
218
|
+
sendErrorMessage(statusCode, extraErrorDescription) {
|
|
219
|
+
// When the Client receives an Error Message it reports the error to the application and closes the TransportConnection gracefully.
|
|
220
|
+
// If a Client encounters a fatal error, it shall report the error to the application and send a CloseSecureChannel Message.
|
|
221
|
+
/* istanbul ignore next*/
|
|
222
|
+
if (doDebug) {
|
|
223
|
+
debugLog(chalk.red(" sendErrorMessage ") + chalk.cyan(statusCode.toString()));
|
|
224
|
+
debugLog(chalk.red(" extraErrorDescription ") + chalk.cyan(extraErrorDescription));
|
|
225
|
+
}
|
|
226
|
+
const reason = `${statusCode.toString()}:${extraErrorDescription || ""}`;
|
|
227
|
+
const errorResponse = new TCPErrorMessage_1.TCPErrorMessage({
|
|
228
|
+
statusCode,
|
|
229
|
+
reason
|
|
230
|
+
});
|
|
231
|
+
const messageChunk = (0, tools_1.packTcpMessage)("ERR", errorResponse);
|
|
232
|
+
this.write(messageChunk);
|
|
233
|
+
}
|
|
234
|
+
prematureTerminate(err, statusCode) {
|
|
235
|
+
// https://reference.opcfoundation.org/v104/Core/docs/Part6/6.7.3/
|
|
236
|
+
debugLog("prematureTerminate", err ? err.message : "", statusCode.toString());
|
|
237
|
+
if (this._socket) {
|
|
238
|
+
err.message = "premature socket termination " + err.message;
|
|
239
|
+
// we consider this as an error
|
|
240
|
+
const _s = this._socket;
|
|
241
|
+
_s.end();
|
|
242
|
+
_s.destroy(); // new Error("Socket has timed out"));
|
|
243
|
+
_s.emit("error", err);
|
|
244
|
+
this._socket = null;
|
|
245
|
+
this.dispose();
|
|
246
|
+
}
|
|
247
|
+
// this.gracefullShutdown(err);
|
|
248
|
+
}
|
|
249
|
+
/**
|
|
250
|
+
* @method _install_one_time_message_receiver
|
|
251
|
+
*
|
|
252
|
+
* install a one time message receiver callback
|
|
253
|
+
*
|
|
254
|
+
* Rules:
|
|
255
|
+
* * TCP_transport will not emit the ```message``` event, while the "one time message receiver" is in operation.
|
|
256
|
+
* * the TCP_transport will wait for the next complete message chunk and call the provided callback func
|
|
257
|
+
* ```callback(null,messageChunk);```
|
|
258
|
+
*
|
|
259
|
+
* if a messageChunk is not received within ```TCP_transport.timeout``` or if the underlying socket reports
|
|
260
|
+
* an error, the callback function will be called with an Error.
|
|
261
|
+
*
|
|
262
|
+
*/
|
|
263
|
+
_install_one_time_message_receiver(callback) {
|
|
264
|
+
(0, node_opcua_assert_1.assert)(!this._theCallback, "callback already set");
|
|
265
|
+
(0, node_opcua_assert_1.assert)(typeof callback === "function");
|
|
266
|
+
this._theCallback = callback;
|
|
267
|
+
this._start_one_time_message_receiver();
|
|
268
|
+
}
|
|
269
|
+
_fulfill_pending_promises(err, data) {
|
|
270
|
+
this._cleanup_timers();
|
|
271
|
+
if (this._socket && this._on_error_during_one_time_message_receiver) {
|
|
272
|
+
this._socket.removeListener("close", this._on_error_during_one_time_message_receiver);
|
|
273
|
+
this._on_error_during_one_time_message_receiver = null;
|
|
274
|
+
}
|
|
275
|
+
const callback = this._theCallback;
|
|
276
|
+
this._theCallback = undefined;
|
|
277
|
+
if (callback) {
|
|
278
|
+
callback(err, data);
|
|
279
|
+
return true;
|
|
280
|
+
}
|
|
281
|
+
return false;
|
|
282
|
+
}
|
|
283
|
+
_on_message_chunk_received(messageChunk) {
|
|
284
|
+
if (utils_1.doTraceIncomingChunk) {
|
|
285
|
+
console.log((0, node_opcua_debug_1.hexDump)(messageChunk));
|
|
286
|
+
}
|
|
287
|
+
const hadCallback = this._fulfill_pending_promises(null, messageChunk);
|
|
288
|
+
this.chunkReadCount++;
|
|
289
|
+
if (!hadCallback) {
|
|
290
|
+
this.emit("chunk", messageChunk);
|
|
291
|
+
}
|
|
292
|
+
}
|
|
293
|
+
_cleanup_timers() {
|
|
294
|
+
if (this._timerId) {
|
|
295
|
+
clearTimeout(this._timerId);
|
|
296
|
+
this._timerId = null;
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
_start_one_time_message_receiver() {
|
|
300
|
+
(0, node_opcua_assert_1.assert)(!this._timerId, "timer already started");
|
|
301
|
+
// Setup timeout detection timer ....
|
|
302
|
+
this._timerId = setTimeout(() => {
|
|
303
|
+
this._timerId = null;
|
|
304
|
+
this._fulfill_pending_promises(new Error(`Timeout in waiting for data on socket ( timeout was = ${this.timeout} ms)`));
|
|
305
|
+
}, this.timeout);
|
|
306
|
+
// also monitored
|
|
307
|
+
if (this._socket) {
|
|
308
|
+
// to do = intercept socket error as well
|
|
309
|
+
this._on_error_during_one_time_message_receiver = (err) => {
|
|
310
|
+
this._fulfill_pending_promises(new Error(`ERROR in waiting for data on socket ( timeout was = ${this.timeout} ms) ` + (err === null || err === void 0 ? void 0 : err.message)));
|
|
311
|
+
};
|
|
312
|
+
this._socket.on("close", this._on_error_during_one_time_message_receiver);
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
on_socket_closed(err) {
|
|
316
|
+
if (this._onSocketClosedHasBeenCalled) {
|
|
317
|
+
return;
|
|
318
|
+
}
|
|
319
|
+
(0, node_opcua_assert_1.assert)(!this._onSocketClosedHasBeenCalled);
|
|
320
|
+
this._onSocketClosedHasBeenCalled = true; // we don't want to send close event twice ...
|
|
321
|
+
this.emit("socket_closed", err || null);
|
|
322
|
+
}
|
|
323
|
+
_on_socket_data(data) {
|
|
324
|
+
// istanbul ignore next
|
|
325
|
+
if (!this.packetAssembler) {
|
|
326
|
+
throw new Error("internal Error");
|
|
327
|
+
}
|
|
328
|
+
this.bytesRead += data.length;
|
|
329
|
+
if (data.length > 0) {
|
|
330
|
+
this.packetAssembler.feed(data);
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
_on_socket_close(hadError) {
|
|
334
|
+
// istanbul ignore next
|
|
335
|
+
if (doDebug) {
|
|
336
|
+
debugLog(chalk.red(" SOCKET CLOSE : "), chalk.yellow("had_error ="), chalk.cyan(hadError.toString()), this.name);
|
|
337
|
+
}
|
|
338
|
+
if (this._socket) {
|
|
339
|
+
debugLog(" remote address = ", this._socket.remoteAddress, " ", this._socket.remoteFamily, " ", this._socket.remotePort);
|
|
340
|
+
}
|
|
341
|
+
if (hadError) {
|
|
342
|
+
if (this._socket) {
|
|
343
|
+
this._socket.destroy();
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
const err = hadError ? new Error("ERROR IN SOCKET " + hadError.toString()) : undefined;
|
|
347
|
+
this.on_socket_closed(err);
|
|
348
|
+
this.dispose();
|
|
349
|
+
}
|
|
350
|
+
_on_socket_ended_message(err) {
|
|
351
|
+
if (this._disconnecting) {
|
|
352
|
+
return;
|
|
353
|
+
}
|
|
354
|
+
debugLog(chalk.red("Transport Connection ended") + " " + this.name);
|
|
355
|
+
(0, node_opcua_assert_1.assert)(!this._disconnecting);
|
|
356
|
+
err = err || new Error("_socket has been disconnected by third party");
|
|
357
|
+
this.on_socket_ended(err);
|
|
358
|
+
this._disconnecting = true;
|
|
359
|
+
debugLog(" bytesRead = ", this.bytesRead);
|
|
360
|
+
debugLog(" bytesWritten = ", this.bytesWritten);
|
|
361
|
+
this._fulfill_pending_promises(new Error("Connection aborted - ended by server : " + (err ? err.message : "")));
|
|
362
|
+
}
|
|
363
|
+
_on_socket_end(err) {
|
|
364
|
+
// istanbul ignore next
|
|
365
|
+
if (doDebug) {
|
|
366
|
+
debugLog(chalk.red(" SOCKET END : err="), chalk.yellow(err ? err.message : "null"), this.name);
|
|
367
|
+
}
|
|
368
|
+
this._on_socket_ended_message(err);
|
|
369
|
+
}
|
|
370
|
+
_on_socket_error(err) {
|
|
371
|
+
// istanbul ignore next
|
|
372
|
+
if (doDebug) {
|
|
373
|
+
debugLog(chalk.red(" SOCKET ERROR : "), chalk.yellow(err.message), this.name);
|
|
374
|
+
}
|
|
375
|
+
// node The "close" event will be called directly following this event.
|
|
376
|
+
}
|
|
377
|
+
}
|
|
378
|
+
TCP_transport.registry = new node_opcua_object_registry_1.ObjectRegistry();
|
|
379
|
+
exports.TCP_transport = TCP_transport;
|
|
380
|
+
//# sourceMappingURL=tcp_transport.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"tcp_transport.js","sourceRoot":"","sources":["../../source/tcp_transport.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,mCAAsC;AAEtC,+BAA+B;AAE/B,yDAA2C;AAC3C,uDAA0G;AAC1G,2EAA4D;AAC5D,6EAAwF;AAGxF,iDAA8C;AAC9C,iEAA8D;AAC9D,mCAA+C;AAC/C,uDAAoD;AACpD,mCAAyC;AAEzC,MAAM,QAAQ,GAAG,IAAA,gCAAa,EAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,OAAO,GAAG,IAAA,iCAAc,EAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,QAAQ,GAAG,IAAA,gCAAa,EAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,UAAU,GAAG,IAAA,kCAAe,EAAC,UAAU,CAAC,CAAC;AAQ/C,IAAI,UAAU,GAAe;IACzB,OAAO,EAAE,IAAI;IAEb,OAAO;QACH,QAAQ,CAAC,oBAAoB,CAAC,CAAC;IACnC,CAAC;IAED,GAAG;QACC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;IAC/B,CAAC;CACJ,CAAC;AAEF,SAAgB,gBAAgB,CAAC,UAAsB;IACnD,UAAU,GAAG,UAAU,CAAC;AAC5B,CAAC;AAFD,4CAEC;AAED,SAAgB,gBAAgB;IAC5B,IAAI,UAAU,CAAC,OAAO,EAAE;QACpB,MAAM,IAAI,KAAK,CAAC,0FAA0F,CAAC,CAAC;KAC/G;IACD,OAAO,UAAU,CAAC;AACtB,CAAC;AALD,4CAKC;AAED,IAAI,OAAO,GAAG,CAAC,CAAC;AA6BhB,4BAA4B;AAC5B,MAAa,aAAc,SAAQ,qBAAY;IAmC3C;QACI,KAAK,EAAE,CAAC;QAER,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,GAAG,OAAO,CAAC;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SACjF;QACD,uEAAuE;IAC3E,CAAC;;AArbc,sBAAQ,GAAG,IAAI,2CAAc,EAAE,CAAC;AADtC,sCAAa"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
/// <reference types="node" />
|
|
3
|
+
/**
|
|
4
|
+
* @module node-opcua-transport
|
|
5
|
+
*/
|
|
6
|
+
import * as url from "url";
|
|
7
|
+
import { BinaryStream, OutputBinaryStream } from "node-opcua-binary-stream";
|
|
8
|
+
import { BaseUAObject } from "node-opcua-factory";
|
|
9
|
+
export type ConstructorFunc = new (...args: any[]) => BaseUAObject;
|
|
10
|
+
export declare function decodeMessage(stream: BinaryStream, classNameConstructor: ConstructorFunc): BaseUAObject;
|
|
11
|
+
export declare function packTcpMessage(msgType: string, encodeableObject: BaseUAObject): Buffer;
|
|
12
|
+
export declare function parseEndpointUrl(endpointUrl: string): url.Url;
|
|
13
|
+
export declare function is_valid_endpointUrl(endpointUrl: string): boolean;
|
|
14
|
+
export declare function writeTCPMessageHeader(msgType: string, chunkType: string, totalLength: number, stream: OutputBinaryStream | Buffer): void;
|