Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

node-opcua-transport

Package Overview
Dependencies
Maintainers
1
Versions
221
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-opcua-transport - npm Package Compare versions

Comparing version 2.72.2 to 2.73.0

16

dist/source/client_tcp_transport.d.ts

@@ -10,2 +10,3 @@ /// <reference types="node" />

on(eventName: "connection_break", eventHandler: () => void): this;
on(eventName: "connect", eventHandler: () => void): this;
once(eventName: "chunk", eventHandler: (messageChunk: Buffer) => void): this;

@@ -15,3 +16,15 @@ once(eventName: "socket_closed", eventHandler: (err: Error | null) => void): this;

once(eventName: "connection_break", eventHandler: () => void): this;
once(eventName: "connect", eventHandler: () => void): this;
emit(eventName: "chunk", messageChunk: Buffer): boolean;
emit(eventName: "socket_closed", err?: Error | null): boolean;
emit(eventName: "close", err?: Error | null): boolean;
emit(eventName: "connection_break"): boolean;
emit(eventName: "connect"): boolean;
}
export interface TransportSettingsOptions {
maxChunkCount?: number;
maxMessageSize?: number;
receiveBufferSize?: number;
sendBufferSize?: number;
}
/**

@@ -66,3 +79,4 @@ * a ClientTCP_transport connects to a remote server socket and

private _counter;
constructor();
private _helloSettings;
constructor(transportSettings?: TransportSettingsOptions);
dispose(): void;

@@ -69,0 +83,0 @@ connect(endpointUrl: string, callback: ErrorCallback): void;

21

dist/source/client_tcp_transport.js

@@ -34,3 +34,4 @@ "use strict";

socket = (0, net_1.createConnection)({ host: hostname, port });
// // Setting true for noDelay will immediately fire off data each time socket.write() is called.
socket.setKeepAlive(true);
// Setting true for noDelay will immediately fire off data each time socket.write() is called.
socket.setNoDelay(true);

@@ -92,3 +93,3 @@ return socket;

class ClientTCP_transport extends tcp_transport_1.TCP_transport {
constructor() {
constructor(transportSettings) {
super();

@@ -104,2 +105,9 @@ this.connected = false;

this.receiveBufferSize = 4 * 1024;
transportSettings = transportSettings || {};
this._helloSettings = {
maxChunkCount: transportSettings.maxChunkCount || ClientTCP_transport.defaultMaxChunk,
maxMessageSize: transportSettings.maxMessageSize || ClientTCP_transport.defaultMaxMessageSize,
receiveBufferSize: transportSettings.receiveBufferSize || ClientTCP_transport.defaultReceiveBufferSize,
sendBufferSize: transportSettings.sendBufferSize || ClientTCP_transport.defaultSendBufferSize
};
}

@@ -263,2 +271,3 @@ dispose() {

(0, node_opcua_assert_1.assert)(this.endpointUrl.length > 0, " expecting a valid endpoint url");
const { maxChunkCount, maxMessageSize, receiveBufferSize, sendBufferSize } = this._helloSettings;
// Write a message to the socket as soon as the client is connected,

@@ -269,6 +278,6 @@ // the server will receive it as message from the client

protocolVersion: this.protocolVersion,
maxChunkCount: ClientTCP_transport.defaultMaxChunk,
maxMessageSize: ClientTCP_transport.defaultMaxMessageSize,
receiveBufferSize: ClientTCP_transport.defaultReceiveBufferSize,
sendBufferSize: ClientTCP_transport.defaultSendBufferSize
maxChunkCount,
maxMessageSize,
receiveBufferSize,
sendBufferSize
});

@@ -275,0 +284,0 @@ // istanbul ignore next

@@ -36,3 +36,3 @@ "use strict";

name: "endpointUrl",
fieldType: "UAString",
fieldType: "String",
documentation: "The URL of the Endpoint which the Client wished to connect to."

@@ -39,0 +39,0 @@ }

@@ -19,6 +19,35 @@ /// <reference types="node" />

export interface MessageBuilderBase {
/**
*
* notify the observers that a new message is being built
* @event start_chunk
* @param info
* @param data
*/
on(eventName: "startChunk", eventHandler: (info: PacketInfo, data: Buffer) => void): this;
/**
* notify the observers that new message chunk has been received
* @event chunk
* @param messageChunk the raw message chunk
*/
on(eventName: "chunk", eventHandler: (chunk: Buffer) => void): this;
/**
* notify the observers that an error has occurred
* @event error
* @param error the error to raise
*/
on(eventName: "error", eventHandler: (err: Error, statusCode: StatusCode, requestId: number | null) => void): this;
/**
* notify the observers that a full message has been received
* @event full_message_body
* @param full_message_body the full message body made of all concatenated chunks.
*/
on(eventName: "full_message_body", eventHandler: (fullMessageBody: Buffer) => void): this;
/**
*
* @param eventName "abandon"
* @param info
* @param data
*/
on(eventName: "abandon", eventHandler: (requestId: number) => void): this;
emit(eventName: "startChunk", info: PacketInfo, data: Buffer): boolean;

@@ -28,2 +57,3 @@ emit(eventName: "chunk", chunk: Buffer): boolean;

emit(eventName: "full_message_body", fullMessageBody: Buffer): boolean;
emit(eventName: "abandon", requestId: number): boolean;
}

@@ -73,2 +103,3 @@ /**

protected _read_headers(binaryStream: BinaryStream): boolean;
protected _report_abandon(channelId: number, tokenId: number, sequenceHeader: SequenceHeader): false;
protected _report_error(statusCode: StatusCode, errorMessage: string): false;

@@ -75,0 +106,0 @@ private _init_new;

@@ -9,2 +9,3 @@ "use strict";

const node_opcua_assert_1 = require("node-opcua-assert");
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
const node_opcua_binary_stream_1 = require("node-opcua-binary-stream");

@@ -70,9 +71,2 @@ const node_opcua_buffer_utils_1 = require("node-opcua-buffer-utils");

}
/**
*
* notify the observers that a new message is being built
* @event start_chunk
* @param info
* @param data
*/
this.emit("startChunk", info, data);

@@ -124,12 +118,15 @@ });

}
_report_abandon(channelId, tokenId, sequenceHeader) {
// the server has not been able to send a complete message and has abandoned the request
// the connection can probably continue
this._hasReceivedError = false; ///
this.emit("abandon", sequenceHeader.requestId);
return false;
}
_report_error(statusCode, errorMessage) {
var _a;
this._hasReceivedError = true;
/**
* notify the observers that an error has occurred
* @event error
* @param error the error to raise
*/
debugLog("Error ", this.id, errorMessage);
// xx errorLog(new Error());
this.emit("error", new Error(errorMessage), statusCode, this.sequenceHeader ? this.sequenceHeader.requestId : null);
this.emit("error", new Error(errorMessage), statusCode, ((_a = this.sequenceHeader) === null || _a === void 0 ? void 0 : _a.requestId) || null);
return false;

@@ -192,32 +189,50 @@ }

const messageHeader = (0, node_opcua_chunkmanager_1.readMessageHeader)(new node_opcua_binary_stream_1.BinaryStream(chunk));
/**
* notify the observers that new message chunk has been received
* @event chunk
* @param messageChunk the raw message chunk
*/
this.emit("chunk", chunk);
if (messageHeader.isFinal === "F") {
// last message
this._append(chunk);
if (this._hasReceivedError) {
return false;
if (messageHeader.msgType === "ERR") {
const binaryStream = new node_opcua_binary_stream_1.BinaryStream(chunk);
binaryStream.length = 8;
const errorCode = (0, node_opcua_basic_types_1.decodeStatusCode)(binaryStream);
const message = (0, node_opcua_basic_types_1.decodeString)(binaryStream);
this._report_error(errorCode, message || "Error message not specified");
return true;
}
const fullMessageBody = this.blocks.length === 1 ? this.blocks[0] : Buffer.concat(this.blocks);
if (doPerfMonitoring) {
// record tick 1: when a complete message has been received ( all chunks assembled)
this._tick1 = (0, node_opcua_utils_1.get_clock_tick)();
else {
this._append(chunk);
// last message
if (this._hasReceivedError) {
return false;
}
const fullMessageBody = this.blocks.length === 1 ? this.blocks[0] : Buffer.concat(this.blocks);
if (doPerfMonitoring) {
// record tick 1: when a complete message has been received ( all chunks assembled)
this._tick1 = (0, node_opcua_utils_1.get_clock_tick)();
}
this.emit("full_message_body", fullMessageBody);
this._decodeMessageBody(fullMessageBody);
// be ready for next block
this._init_new();
return true;
}
/**
* notify the observers that a full message has been received
* @event full_message_body
* @param full_message_body the full message body made of all concatenated chunks.
*/
this.emit("full_message_body", fullMessageBody);
this._decodeMessageBody(fullMessageBody);
// be ready for next block
this._init_new();
return true;
}
else if (messageHeader.isFinal === "A") {
return this._report_error(status_codes_1.StatusCodes2.BadRequestInterrupted, "received and Abort Message");
try {
// only valid for MSG, according to spec
const stream = new node_opcua_binary_stream_1.BinaryStream(chunk);
(0, node_opcua_chunkmanager_1.readMessageHeader)(stream);
(0, node_opcua_assert_1.assert)(stream.length === 8);
// instead of
// const securityHeader = new SymmetricAlgorithmSecurityHeader();
// securityHeader.decode(stream);
const channelId = stream.readUInt32();
const tokenId = (0, node_opcua_basic_types_1.decodeUInt32)(stream);
const sequenceHeader = new node_opcua_chunkmanager_1.SequenceHeader();
sequenceHeader.decode(stream);
return this._report_abandon(channelId, tokenId, sequenceHeader);
}
catch (err) {
warningLog((0, node_opcua_debug_1.hexDump)(chunk));
warningLog("Cannot interpret message chunk: ", err.message);
return this._report_error(status_codes_1.StatusCodes2.BadTcpInternalError, "Error decoding message header " + err.message);
}
}

@@ -224,0 +239,0 @@ else if (messageHeader.isFinal === "C") {

@@ -110,3 +110,3 @@ "use strict";

const minBufferSize = 8192;
const maxBufferSize = 64 * 1024;
const maxBufferSize = 8 * 64 * 1024;
const minMaxMessageSize = 128 * 1024;

@@ -118,4 +118,4 @@ const defaultMaxMessageSize = 16 * 1024 * 1024;

const maxMaxChunkCount = 9000;
const receiveBufferSize = 32 * 1024;
const sendBufferSize = 32 * 1024;
const defaultReceiveBufferSize = 64 * 1024;
const defaultSendBufferSize = 64 * 1024;
if (!helloMessage.maxChunkCount && helloMessage.sendBufferSize) {

@@ -125,4 +125,4 @@ helloMessage.maxChunkCount = helloMessage.maxMessageSize / helloMessage.sendBufferSize;

this.setLimits({
receiveBufferSize: clamp_value(helloMessage.receiveBufferSize || receiveBufferSize, minBufferSize, maxBufferSize),
sendBufferSize: clamp_value(helloMessage.sendBufferSize || sendBufferSize, minBufferSize, maxBufferSize),
receiveBufferSize: clamp_value(helloMessage.receiveBufferSize || defaultReceiveBufferSize, minBufferSize, maxBufferSize),
sendBufferSize: clamp_value(helloMessage.sendBufferSize || defaultSendBufferSize, minBufferSize, maxBufferSize),
maxMessageSize: clamp_value(helloMessage.maxMessageSize || defaultMaxMessageSize, minMaxMessageSize, maxMaxMessageSize),

@@ -129,0 +129,0 @@ maxChunkCount: clamp_value(helloMessage.maxChunkCount || defaultMaxChunkCount, minMaxChunkCount, maxMaxChunkCount)

@@ -19,4 +19,18 @@ /// <reference types="node" />

export interface TCP_transport {
/**
* notify the observers that a message chunk has been received
* @event chunk
* @param message_chunk the message chunk
*/
on(eventName: "chunk", eventHandler: (messageChunk: Buffer) => void): this;
/**
* notify the observers that the transport layer has been disconnected.
* @event socket_closed
* @param err the Error object or null
*/
on(eventName: "socket_closed", eventHandler: (err: Error | null) => void): this;
/**
* notify the observers that the transport layer has been disconnected.
* @event close
*/
on(eventName: "close", eventHandler: (err: Error | null) => void): this;

@@ -26,2 +40,5 @@ once(eventName: "chunk", eventHandler: (messageChunk: Buffer) => void): this;

once(eventName: "close", eventHandler: (err: Error | null) => void): this;
emit(eventName: "socket_closed", err?: Error | null): boolean;
emit(eventName: "close", err?: Error | null): boolean;
emit(eventName: "chunk", messageChunk: Buffer): boolean;
}

@@ -28,0 +45,0 @@ export declare class TCP_transport extends EventEmitter {

@@ -21,2 +21,3 @@ "use strict";

const errorLog = (0, node_opcua_debug_1.make_errorLog)(__filename);
const warningLog = (0, node_opcua_debug_1.make_warningLog)(__filename);
let fakeSocket = {

@@ -156,10 +157,9 @@ invalid: true,

on_socket_ended(err) {
(0, node_opcua_assert_1.assert)(!this._onSocketEndedHasBeenCalled);
this._onSocketEndedHasBeenCalled = true; // we don't want to send close event twice ...
/**
* notify the observers that the transport layer has been disconnected.
* @event close
* @param err the Error object or null
*/
this.emit("close", err || null);
if (!this._onSocketEndedHasBeenCalled) {
this._onSocketEndedHasBeenCalled = true; // we don't want to send close event twice ...
this.emit("close", err || null);
}
else {
debugLog("on_socket_ended has already been called");
}
}

@@ -289,7 +289,2 @@ _install_packetAssembler() {

if (!hadCallback) {
/**
* notify the observers that a message chunk has been received
* @event message
* @param message_chunk the message chunk
*/
this.emit("chunk", messageChunk);

@@ -326,7 +321,2 @@ }

this._onSocketClosedHasBeenCalled = true; // we don't want to send close event twice ...
/**
* notify the observers that the transport layer has been disconnected.
* @event socket_closed
* @param err the Error object or null
*/
this.emit("socket_closed", err || null);

@@ -333,0 +323,0 @@ }

{
"name": "node-opcua-transport",
"version": "2.72.2",
"version": "2.73.0",
"description": "pure nodejs OPCUA SDK - module -transport",

@@ -17,13 +17,13 @@ "main": "./dist/source/index.js",

"node-opcua-assert": "2.66.0",
"node-opcua-basic-types": "2.72.1",
"node-opcua-binary-stream": "2.71.0",
"node-opcua-basic-types": "2.73.0",
"node-opcua-binary-stream": "2.73.0",
"node-opcua-buffer-utils": "2.71.0",
"node-opcua-chunkmanager": "2.72.1",
"node-opcua-chunkmanager": "2.73.0",
"node-opcua-debug": "2.71.0",
"node-opcua-factory": "2.72.1",
"node-opcua-factory": "2.73.0",
"node-opcua-nodeid": "2.71.0",
"node-opcua-object-registry": "2.71.0",
"node-opcua-packet-assembler": "2.71.0",
"node-opcua-status-code": "2.71.0",
"node-opcua-types": "2.72.2",
"node-opcua-status-code": "2.73.0",
"node-opcua-types": "2.73.0",
"node-opcua-utils": "2.71.0"

@@ -51,3 +51,3 @@ },

"homepage": "http://node-opcua.github.io/",
"gitHead": "07dcdd8e8c7f2b55544c6e23023093e35674829c"
"gitHead": "b23a87c1ef777c0d8b680f45ee77e2a319feb092"
}

@@ -38,3 +38,5 @@ /**

// // Setting true for noDelay will immediately fire off data each time socket.write() is called.
socket.setKeepAlive(true);
// Setting true for noDelay will immediately fire off data each time socket.write() is called.
socket.setNoDelay(true);

@@ -64,2 +66,3 @@

on(eventName: "connection_break", eventHandler: () => void): this;
on(eventName: "connect", eventHandler: () => void): this;

@@ -70,4 +73,18 @@ once(eventName: "chunk", eventHandler: (messageChunk: Buffer) => void): this;

once(eventName: "connection_break", eventHandler: () => void): this;
once(eventName: "connect", eventHandler: () => void): this;
emit(eventName: "chunk", messageChunk: Buffer): boolean;
emit(eventName: "socket_closed", err?: Error | null): boolean;
emit(eventName: "close", err?: Error | null): boolean;
emit(eventName: "connection_break"): boolean;
emit(eventName: "connect"): boolean;
}
export interface TransportSettingsOptions {
maxChunkCount?: number;
maxMessageSize?: number;
receiveBufferSize?: number;
sendBufferSize?: number;
}
/**

@@ -124,4 +141,9 @@ * a ClientTCP_transport connects to a remote server socket and

private _counter: number;
constructor() {
private _helloSettings: {
maxChunkCount: number;
maxMessageSize: number;
receiveBufferSize: number;
sendBufferSize: number;
};
constructor(transportSettings?: TransportSettingsOptions) {
super();

@@ -138,2 +160,10 @@ this.connected = false;

this.receiveBufferSize = 4 * 1024;
transportSettings = transportSettings || {};
this._helloSettings = {
maxChunkCount: transportSettings.maxChunkCount || ClientTCP_transport.defaultMaxChunk,
maxMessageSize: transportSettings.maxMessageSize || ClientTCP_transport.defaultMaxMessageSize,
receiveBufferSize: transportSettings.receiveBufferSize || ClientTCP_transport.defaultReceiveBufferSize,
sendBufferSize: transportSettings.sendBufferSize || ClientTCP_transport.defaultSendBufferSize
};
}

@@ -321,2 +351,4 @@

const { maxChunkCount, maxMessageSize, receiveBufferSize, sendBufferSize } = this._helloSettings;
// Write a message to the socket as soon as the client is connected,

@@ -327,6 +359,6 @@ // the server will receive it as message from the client

protocolVersion: this.protocolVersion,
maxChunkCount: ClientTCP_transport.defaultMaxChunk,
maxMessageSize: ClientTCP_transport.defaultMaxMessageSize,
receiveBufferSize: ClientTCP_transport.defaultReceiveBufferSize,
sendBufferSize: ClientTCP_transport.defaultSendBufferSize
maxChunkCount,
maxMessageSize,
receiveBufferSize,
sendBufferSize
});

@@ -333,0 +365,0 @@ // istanbul ignore next

@@ -53,3 +53,3 @@ /**

fieldType: "UAString",
fieldType: "String",

@@ -56,0 +56,0 @@ documentation: "The URL of the Endpoint which the Client wished to connect to."

@@ -7,6 +7,7 @@ /**

import { decodeStatusCode, decodeString, decodeUInt32 } from "node-opcua-basic-types";
import { BinaryStream } from "node-opcua-binary-stream";
import { createFastUninitializedBuffer } from "node-opcua-buffer-utils";
import { readMessageHeader, SequenceHeader } from "node-opcua-chunkmanager";
import { make_errorLog, make_debugLog, make_warningLog } from "node-opcua-debug";
import { make_errorLog, make_debugLog, make_warningLog, hexDump } from "node-opcua-debug";
import { MessageHeader, PacketAssembler, PacketInfo } from "node-opcua-packet-assembler";

@@ -16,3 +17,2 @@ import { StatusCode } from "node-opcua-status-code";

import { StatusCodes2 } from "./status_codes";
const doPerfMonitoring = process.env.NODEOPCUADEBUG && process.env.NODEOPCUADEBUG.indexOf("PERF") >= 0;

@@ -41,7 +41,40 @@

export interface MessageBuilderBase {
/**
*
* notify the observers that a new message is being built
* @event start_chunk
* @param info
* @param data
*/
on(eventName: "startChunk", eventHandler: (info: PacketInfo, data: Buffer) => void): this;
/**
* notify the observers that new message chunk has been received
* @event chunk
* @param messageChunk the raw message chunk
*/
on(eventName: "chunk", eventHandler: (chunk: Buffer) => void): this;
/**
* notify the observers that an error has occurred
* @event error
* @param error the error to raise
*/
on(eventName: "error", eventHandler: (err: Error, statusCode: StatusCode, requestId: number | null) => void): this;
/**
* notify the observers that a full message has been received
* @event full_message_body
* @param full_message_body the full message body made of all concatenated chunks.
*/
on(eventName: "full_message_body", eventHandler: (fullMessageBody: Buffer) => void): this;
/**
*
* @param eventName "abandon"
* @param info
* @param data
*/
on(eventName: "abandon", eventHandler: (requestId: number) => void): this;
emit(eventName: "startChunk", info: PacketInfo, data: Buffer): boolean;

@@ -51,2 +84,3 @@ emit(eventName: "chunk", chunk: Buffer): boolean;

emit(eventName: "full_message_body", fullMessageBody: Buffer): boolean;
emit(eventName: "abandon", requestId: number): boolean;
}

@@ -132,9 +166,2 @@ /**

}
/**
*
* notify the observers that a new message is being built
* @event start_chunk
* @param info
* @param data
*/
this.emit("startChunk", info, data);

@@ -194,12 +221,15 @@ });

protected _report_abandon(channelId: number, tokenId: number, sequenceHeader: SequenceHeader): false {
// the server has not been able to send a complete message and has abandoned the request
// the connection can probably continue
this._hasReceivedError = false; ///
this.emit("abandon", sequenceHeader.requestId);
return false;
}
protected _report_error(statusCode: StatusCode, errorMessage: string): false {
this._hasReceivedError = true;
/**
* notify the observers that an error has occurred
* @event error
* @param error the error to raise
*/
debugLog("Error ", this.id, errorMessage);
// xx errorLog(new Error());
this.emit("error", new Error(errorMessage), statusCode, this.sequenceHeader ? this.sequenceHeader.requestId : null);
this.emit("error", new Error(errorMessage), statusCode, this.sequenceHeader?.requestId || null);
return false;

@@ -280,38 +310,60 @@ }

private _feed_messageChunk(chunk: Buffer) {
private _feed_messageChunk(chunk: Buffer): boolean {
assert(chunk);
const messageHeader = readMessageHeader(new BinaryStream(chunk));
/**
* notify the observers that new message chunk has been received
* @event chunk
* @param messageChunk the raw message chunk
*/
this.emit("chunk", chunk);
if (messageHeader.isFinal === "F") {
// last message
this._append(chunk);
if (this._hasReceivedError) {
return false;
}
if (messageHeader.msgType === "ERR") {
const binaryStream = new BinaryStream(chunk);
binaryStream.length = 8;
const errorCode = decodeStatusCode(binaryStream);
const message = decodeString(binaryStream);
this._report_error(errorCode, message || "Error message not specified");
return true;
} else {
this._append(chunk);
// last message
if (this._hasReceivedError) {
return false;
}
const fullMessageBody: Buffer = this.blocks.length === 1 ? this.blocks[0] : Buffer.concat(this.blocks);
const fullMessageBody: Buffer = this.blocks.length === 1 ? this.blocks[0] : Buffer.concat(this.blocks);
if (doPerfMonitoring) {
// record tick 1: when a complete message has been received ( all chunks assembled)
this._tick1 = get_clock_tick();
if (doPerfMonitoring) {
// record tick 1: when a complete message has been received ( all chunks assembled)
this._tick1 = get_clock_tick();
}
this.emit("full_message_body", fullMessageBody);
this._decodeMessageBody(fullMessageBody);
// be ready for next block
this._init_new();
return true;
}
/**
* notify the observers that a full message has been received
* @event full_message_body
* @param full_message_body the full message body made of all concatenated chunks.
*/
this.emit("full_message_body", fullMessageBody);
} else if (messageHeader.isFinal === "A") {
try {
// only valid for MSG, according to spec
const stream = new BinaryStream(chunk);
readMessageHeader(stream);
assert(stream.length === 8);
// instead of
// const securityHeader = new SymmetricAlgorithmSecurityHeader();
// securityHeader.decode(stream);
const channelId = stream.readUInt32();
const tokenId = decodeUInt32(stream);
this._decodeMessageBody(fullMessageBody);
// be ready for next block
this._init_new();
return true;
} else if (messageHeader.isFinal === "A") {
return this._report_error(StatusCodes2.BadRequestInterrupted, "received and Abort Message");
const sequenceHeader = new SequenceHeader();
sequenceHeader.decode(stream);
return this._report_abandon(channelId, tokenId, sequenceHeader);
} catch (err) {
warningLog(hexDump(chunk));
warningLog("Cannot interpret message chunk: ", (err as Error).message);
return this._report_error(
StatusCodes2.BadTcpInternalError,
"Error decoding message header " + (err as Error).message
);
}
} else if (messageHeader.isFinal === "C") {

@@ -318,0 +370,0 @@ return this._append(chunk);

@@ -73,3 +73,2 @@ /**

protected _write_chunk(messageChunk: Buffer): void {
// istanbul ignore next

@@ -84,3 +83,3 @@ if (this.sendBufferSize > 0 && messageChunk.length > this.sendBufferSize) {

}
super._write_chunk(messageChunk);

@@ -110,2 +109,3 @@ }

assert(typeof callback === "function", "expecting a valid callback ");
this._install_socket(socket);

@@ -123,3 +123,3 @@ this._install_HEL_message_receiver(callback);

doDebug && debugLog(chalk.cyan("_abortWithError"));
/* istanbul ignore next */

@@ -148,3 +148,3 @@ if (this._aborted) {

const minBufferSize = 8192;
const maxBufferSize = 64 * 1024;
const maxBufferSize = 8 * 64 * 1024;

@@ -159,4 +159,4 @@ const minMaxMessageSize = 128 * 1024;

const receiveBufferSize = 32 * 1024;
const sendBufferSize = 32 * 1024;
const defaultReceiveBufferSize = 64 * 1024;
const defaultSendBufferSize = 64 * 1024;

@@ -168,4 +168,8 @@ if (!helloMessage.maxChunkCount && helloMessage.sendBufferSize) {

this.setLimits({
receiveBufferSize: clamp_value(helloMessage.receiveBufferSize || receiveBufferSize, minBufferSize, maxBufferSize),
sendBufferSize: clamp_value(helloMessage.sendBufferSize || sendBufferSize, minBufferSize, maxBufferSize),
receiveBufferSize: clamp_value(
helloMessage.receiveBufferSize || defaultReceiveBufferSize,
minBufferSize,
maxBufferSize
),
sendBufferSize: clamp_value(helloMessage.sendBufferSize || defaultSendBufferSize, minBufferSize, maxBufferSize),
maxMessageSize: clamp_value(helloMessage.maxMessageSize || defaultMaxMessageSize, minMaxMessageSize, maxMaxMessageSize),

@@ -172,0 +176,0 @@ maxChunkCount: clamp_value(helloMessage.maxChunkCount || defaultMaxChunkCount, minMaxChunkCount, maxMaxChunkCount)

@@ -9,4 +9,3 @@ /**

import { assert } from "node-opcua-assert";
import { BinaryStream } from "node-opcua-binary-stream";
import { make_debugLog, checkDebugFlag, make_errorLog, hexDump } from "node-opcua-debug";
import { make_debugLog, checkDebugFlag, make_errorLog, hexDump, make_warningLog } from "node-opcua-debug";
import { ObjectRegistry } from "node-opcua-object-registry";

@@ -25,2 +24,3 @@ import { PacketAssembler, PacketAssemblerErrorCode } from "node-opcua-packet-assembler";

const errorLog = make_errorLog(__filename);
const warningLog = make_warningLog(__filename);

@@ -59,4 +59,18 @@ export interface MockSocket {

export interface TCP_transport {
/**
* notify the observers that a message chunk has been received
* @event chunk
* @param message_chunk the message chunk
*/
on(eventName: "chunk", eventHandler: (messageChunk: Buffer) => void): this;
/**
* notify the observers that the transport layer has been disconnected.
* @event socket_closed
* @param err the Error object or null
*/
on(eventName: "socket_closed", eventHandler: (err: Error | null) => void): this;
/**
* notify the observers that the transport layer has been disconnected.
* @event close
*/
on(eventName: "close", eventHandler: (err: Error | null) => void): this;

@@ -67,2 +81,6 @@

once(eventName: "close", eventHandler: (err: Error | null) => void): this;
emit(eventName: "socket_closed", err?: Error | null): boolean;
emit(eventName: "close", err?: Error | null): boolean;
emit(eventName: "chunk", messageChunk: Buffer): boolean;
}

@@ -244,10 +262,8 @@ // tslint:disable:class-name

protected on_socket_ended(err: Error | null): void {
assert(!this._onSocketEndedHasBeenCalled);
this._onSocketEndedHasBeenCalled = true; // we don't want to send close event twice ...
/**
* notify the observers that the transport layer has been disconnected.
* @event close
* @param err the Error object or null
*/
this.emit("close", err || null);
if (!this._onSocketEndedHasBeenCalled) {
this._onSocketEndedHasBeenCalled = true; // we don't want to send close event twice ...
this.emit("close", err || null);
} else {
debugLog("on_socket_ended has already been called");
}
}

@@ -308,3 +324,3 @@

// let use a large timeout here to make sure that we not conflict with our internal timeout
this._socket!.setTimeout(this.timeout + 2000, () => {
this._socket.setTimeout(this.timeout + 2000, () => {
debugLog(` _socket ${this.name} has timed out (timeout = ${this.timeout})`);

@@ -398,7 +414,2 @@ this.prematureTerminate(new Error("socket timeout : timeout=" + this.timeout), StatusCodes2.BadTimeout);

if (!hadCallback) {
/**
* notify the observers that a message chunk has been received
* @event message
* @param message_chunk the message chunk
*/
this.emit("chunk", messageChunk);

@@ -442,7 +453,2 @@ }

this._onSocketClosedHasBeenCalled = true; // we don't want to send close event twice ...
/**
* notify the observers that the transport layer has been disconnected.
* @event socket_closed
* @param err the Error object or null
*/
this.emit("socket_closed", err || null);

@@ -449,0 +455,0 @@ }

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc