node-opcua-transport
Advanced tools
Comparing version 2.10.0 to 2.11.0
@@ -17,2 +17,3 @@ "use strict"; | ||
const errorLog = node_opcua_debug_1.make_errorLog("MessageBuilder"); | ||
const debugLog = node_opcua_debug_1.make_debugLog("MessageBuilder"); | ||
function readRawMessageHeader(data) { | ||
@@ -110,3 +111,3 @@ const messageHeader = node_opcua_chunkmanager_1.readMessageHeader(new node_opcua_binary_stream_1.BinaryStream(data)); | ||
*/ | ||
errorLog("Error ", this.id, errorMessage); | ||
debugLog("Error ", this.id, errorMessage); | ||
// xx errorLog(new Error()); | ||
@@ -113,0 +114,0 @@ this.emit("error", new Error(errorMessage), this.sequenceHeader ? this.sequenceHeader.requestId : null); |
@@ -13,2 +13,3 @@ /// <reference types="node" /> | ||
export declare class ServerTCP_transport extends TCP_transport { | ||
static throttleTime: number; | ||
receiveBufferSize: number; | ||
@@ -15,0 +16,0 @@ sendBufferSize: number; |
@@ -93,20 +93,22 @@ "use strict"; | ||
if (!this._aborted) { | ||
this._aborted = 1; | ||
// send the error message and close the connection | ||
node_opcua_assert_1.assert(node_opcua_status_code_1.StatusCodes.hasOwnProperty(statusCode.name)); | ||
/* istanbul ignore next*/ | ||
if (doDebug) { | ||
debugLog(chalk.red(" Server aborting because ") + chalk.cyan(statusCode.name)); | ||
debugLog(chalk.red(" extraErrorDescription ") + chalk.cyan(extraErrorDescription)); | ||
} | ||
const errorResponse = new TCPErrorMessage_1.TCPErrorMessage({ | ||
reason: statusCode.description, | ||
statusCode | ||
}); | ||
const messageChunk = tools_1.packTcpMessage("ERR", errorResponse); | ||
this.write(messageChunk); | ||
this.disconnect(() => { | ||
this._aborted = 2; | ||
callback(new Error(extraErrorDescription + " StatusCode = " + statusCode.name)); | ||
}); | ||
setTimeout(() => { | ||
this._aborted = 1; | ||
// send the error message and close the connection | ||
node_opcua_assert_1.assert(node_opcua_status_code_1.StatusCodes.hasOwnProperty(statusCode.name)); | ||
/* istanbul ignore next*/ | ||
if (doDebug) { | ||
debugLog(chalk.red(" Server aborting because ") + chalk.cyan(statusCode.name)); | ||
debugLog(chalk.red(" extraErrorDescription ") + chalk.cyan(extraErrorDescription)); | ||
} | ||
const errorResponse = new TCPErrorMessage_1.TCPErrorMessage({ | ||
reason: statusCode.description, | ||
statusCode, | ||
}); | ||
const messageChunk = tools_1.packTcpMessage("ERR", errorResponse); | ||
this.write(messageChunk); | ||
this.disconnect(() => { | ||
this._aborted = 2; | ||
callback(new Error(extraErrorDescription + " StatusCode = " + statusCode.name)); | ||
}); | ||
}, ServerTCP_transport.throttleTime); | ||
} | ||
@@ -129,3 +131,3 @@ else { | ||
receiveBufferSize: this.receiveBufferSize, | ||
sendBufferSize: this.sendBufferSize | ||
sendBufferSize: this.sendBufferSize, | ||
}); | ||
@@ -184,3 +186,3 @@ const messageChunk = tools_1.packTcpMessage("ACK", acknowledgeMessage); | ||
} | ||
if (helloMessage.protocolVersion === 0xDEADBEEF || helloMessage.protocolVersion < this.protocolVersion) { | ||
if (helloMessage.protocolVersion === 0xdeadbeef || helloMessage.protocolVersion < this.protocolVersion) { | ||
// Note: 0xDEADBEEF is our special version number to simulate BadProtocolVersionUnsupported in tests | ||
@@ -214,2 +216,3 @@ // invalid protocol version requested by client | ||
exports.ServerTCP_transport = ServerTCP_transport; | ||
ServerTCP_transport.throttleTime = 1000; | ||
//# sourceMappingURL=server_tcp_transport.js.map |
{ | ||
"name": "node-opcua-transport", | ||
"version": "2.10.0", | ||
"version": "2.11.0", | ||
"description": "pure nodejs OPCUA SDK - module -transport", | ||
@@ -15,13 +15,13 @@ "main": "./dist/source/index.js", | ||
"node-opcua-assert": "2.10.0", | ||
"node-opcua-basic-types": "2.10.0", | ||
"node-opcua-binary-stream": "2.10.0", | ||
"node-opcua-basic-types": "2.11.0", | ||
"node-opcua-binary-stream": "2.11.0", | ||
"node-opcua-buffer-utils": "2.10.0", | ||
"node-opcua-chunkmanager": "2.10.0", | ||
"node-opcua-chunkmanager": "2.11.0", | ||
"node-opcua-debug": "2.10.0", | ||
"node-opcua-factory": "2.10.0", | ||
"node-opcua-nodeid": "2.10.0", | ||
"node-opcua-factory": "2.11.0", | ||
"node-opcua-nodeid": "2.11.0", | ||
"node-opcua-object-registry": "2.10.0", | ||
"node-opcua-packet-assembler": "2.10.0", | ||
"node-opcua-status-code": "2.10.0", | ||
"node-opcua-types": "2.10.0", | ||
"node-opcua-status-code": "2.11.0", | ||
"node-opcua-types": "2.11.0", | ||
"node-opcua-utils": "2.10.0", | ||
@@ -35,3 +35,3 @@ "underscore": "^1.10.2" | ||
"node-opcua-debug": "2.8.1", | ||
"node-opcua-generator": "2.10.0", | ||
"node-opcua-generator": "2.11.0", | ||
"should": "^13.2.3", | ||
@@ -55,3 +55,3 @@ "sinon": "^9.0.2" | ||
"homepage": "http://node-opcua.github.io/", | ||
"gitHead": "f1c467c28f8bef1cc04ab54c57a555bd4c95ee45" | ||
"gitHead": "1e1c6d63340aa799867af261437a6a0f5a9a2cdd" | ||
} |
@@ -10,3 +10,3 @@ /** | ||
import { readMessageHeader, SequenceHeader } from "node-opcua-chunkmanager"; | ||
import { make_errorLog } from "node-opcua-debug"; | ||
import { make_errorLog, make_debugLog } from "node-opcua-debug"; | ||
import { PacketAssembler, PacketInfo } from "node-opcua-packet-assembler"; | ||
@@ -18,2 +18,3 @@ import { get_clock_tick } from "node-opcua-utils"; | ||
const errorLog = make_errorLog("MessageBuilder"); | ||
const debugLog = make_debugLog("MessageBuilder"); | ||
@@ -155,3 +156,3 @@ export function readRawMessageHeader(data: Buffer): PacketInfo { | ||
*/ | ||
errorLog("Error ", this.id, errorMessage); | ||
debugLog("Error ", this.id, errorMessage); | ||
// xx errorLog(new Error()); | ||
@@ -158,0 +159,0 @@ this.emit("error", new Error(errorMessage), this.sequenceHeader ? this.sequenceHeader.requestId : null); |
@@ -56,2 +56,3 @@ /** | ||
export class ServerTCP_transport extends TCP_transport { | ||
public static throttleTime: number = 1000; | ||
@@ -108,3 +109,2 @@ public receiveBufferSize: number; | ||
private _abortWithError(statusCode: StatusCode, extraErrorDescription: string, callback: ErrorCallback) { | ||
if (debugLog) { | ||
@@ -118,25 +118,27 @@ debugLog(chalk.cyan("_abortWithError")); | ||
if (!this._aborted) { | ||
this._aborted = 1; | ||
// send the error message and close the connection | ||
assert(StatusCodes.hasOwnProperty(statusCode.name)); | ||
setTimeout(() => { | ||
this._aborted = 1; | ||
// send the error message and close the connection | ||
assert(StatusCodes.hasOwnProperty(statusCode.name)); | ||
/* istanbul ignore next*/ | ||
if (doDebug) { | ||
debugLog(chalk.red(" Server aborting because ") + chalk.cyan(statusCode.name)); | ||
debugLog(chalk.red(" extraErrorDescription ") + chalk.cyan(extraErrorDescription)); | ||
} | ||
/* istanbul ignore next*/ | ||
if (doDebug) { | ||
debugLog(chalk.red(" Server aborting because ") + chalk.cyan(statusCode.name)); | ||
debugLog(chalk.red(" extraErrorDescription ") + chalk.cyan(extraErrorDescription)); | ||
} | ||
const errorResponse = new TCPErrorMessage({ | ||
reason: statusCode.description | ||
, statusCode | ||
}); | ||
const errorResponse = new TCPErrorMessage({ | ||
reason: statusCode.description, | ||
statusCode, | ||
}); | ||
const messageChunk = packTcpMessage("ERR", errorResponse); | ||
const messageChunk = packTcpMessage("ERR", errorResponse); | ||
this.write(messageChunk); | ||
this.disconnect(() => { | ||
this._aborted = 2; | ||
callback(new Error(extraErrorDescription + " StatusCode = " + statusCode.name)); | ||
}); | ||
this.write(messageChunk); | ||
this.disconnect(() => { | ||
this._aborted = 2; | ||
callback(new Error(extraErrorDescription + " StatusCode = " + statusCode.name)); | ||
}); | ||
}, ServerTCP_transport.throttleTime); | ||
} else { | ||
@@ -148,3 +150,2 @@ callback(new Error(statusCode.name)); | ||
private _send_ACK_response(helloMessage: HelloMessage) { | ||
assert(helloMessage.receiveBufferSize >= minimumBufferSize); | ||
@@ -163,3 +164,3 @@ assert(helloMessage.sendBufferSize >= minimumBufferSize); | ||
receiveBufferSize: this.receiveBufferSize, | ||
sendBufferSize: this.sendBufferSize | ||
sendBufferSize: this.sendBufferSize, | ||
}); | ||
@@ -178,7 +179,5 @@ const messageChunk = packTcpMessage("ACK", acknowledgeMessage); | ||
this.write(messageChunk); | ||
} | ||
private _install_HEL_message_receiver(callback: ErrorCallback) { | ||
if (debugLog) { | ||
@@ -217,3 +216,2 @@ debugLog(chalk.cyan("_install_HEL_message_receiver ")); | ||
if (msgType === "HEL") { | ||
assert(data.length >= 24); | ||
@@ -227,14 +225,17 @@ | ||
if (helloMessage.protocolVersion !== this.protocolVersion) { | ||
debugLog(`warning ! client sent helloMessage.protocolVersion = ` + | ||
` 0x${helloMessage.protocolVersion.toString(16)} ` + | ||
`whereas server protocolVersion is 0x${this.protocolVersion.toString(16)}`); | ||
debugLog( | ||
`warning ! client sent helloMessage.protocolVersion = ` + | ||
` 0x${helloMessage.protocolVersion.toString(16)} ` + | ||
`whereas server protocolVersion is 0x${this.protocolVersion.toString(16)}` | ||
); | ||
} | ||
if (helloMessage.protocolVersion === 0xDEADBEEF || helloMessage.protocolVersion < this.protocolVersion) { | ||
if (helloMessage.protocolVersion === 0xdeadbeef || helloMessage.protocolVersion < this.protocolVersion) { | ||
// Note: 0xDEADBEEF is our special version number to simulate BadProtocolVersionUnsupported in tests | ||
// invalid protocol version requested by client | ||
return this._abortWithError(StatusCodes.BadProtocolVersionUnsupported, | ||
"Protocol Version Error" + this.protocolVersion, callback); | ||
return this._abortWithError( | ||
StatusCodes.BadProtocolVersionUnsupported, | ||
"Protocol Version Error" + this.protocolVersion, | ||
callback | ||
); | ||
} | ||
@@ -248,4 +249,7 @@ | ||
if (helloMessage.receiveBufferSize < minimumBufferSize || helloMessage.sendBufferSize < minimumBufferSize) { | ||
return this._abortWithError(StatusCodes.BadConnectionRejected, | ||
"Buffer size too small (should be at least " + minimumBufferSize, callback); | ||
return this._abortWithError( | ||
StatusCodes.BadConnectionRejected, | ||
"Buffer size too small (should be at least " + minimumBufferSize, | ||
callback | ||
); | ||
} | ||
@@ -256,5 +260,3 @@ // the helloMessage shall only be received once. | ||
callback(); // no Error | ||
} else { | ||
// invalid packet , expecting HEL | ||
@@ -267,6 +269,7 @@ /* istanbul ignore next*/ | ||
StatusCodes.BadCommunicationError, | ||
"Expecting 'HEL' message to initiate communication", callback); | ||
"Expecting 'HEL' message to initiate communication", | ||
callback | ||
); | ||
} | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
241147
4015
+ Addednode-opcua-basic-types@2.11.0(transitive)
+ Addednode-opcua-binary-stream@2.11.0(transitive)
+ Addednode-opcua-chunkmanager@2.11.0(transitive)
+ Addednode-opcua-data-model@2.11.0(transitive)
+ Addednode-opcua-data-value@2.11.0(transitive)
+ Addednode-opcua-date-time@2.11.0(transitive)
+ Addednode-opcua-extension-object@2.11.0(transitive)
+ Addednode-opcua-factory@2.11.0(transitive)
+ Addednode-opcua-generator@2.11.0(transitive)
+ Addednode-opcua-nodeid@2.11.0(transitive)
+ Addednode-opcua-numeric-range@2.11.0(transitive)
+ Addednode-opcua-packet-analyzer@2.11.0(transitive)
+ Addednode-opcua-schemas@2.11.0(transitive)
+ Addednode-opcua-status-code@2.11.0(transitive)
+ Addednode-opcua-types@2.11.0(transitive)
+ Addednode-opcua-variant@2.11.0(transitive)
- Removednode-opcua-basic-types@2.10.0(transitive)
- Removednode-opcua-binary-stream@2.10.0(transitive)
- Removednode-opcua-chunkmanager@2.10.0(transitive)
- Removednode-opcua-data-model@2.10.0(transitive)
- Removednode-opcua-data-value@2.10.0(transitive)
- Removednode-opcua-date-time@2.10.0(transitive)
- Removednode-opcua-extension-object@2.10.0(transitive)
- Removednode-opcua-factory@2.10.0(transitive)
- Removednode-opcua-generator@2.10.0(transitive)
- Removednode-opcua-nodeid@2.10.0(transitive)
- Removednode-opcua-numeric-range@2.10.0(transitive)
- Removednode-opcua-packet-analyzer@2.10.0(transitive)
- Removednode-opcua-schemas@2.10.0(transitive)
- Removednode-opcua-status-code@2.10.0(transitive)
- Removednode-opcua-types@2.10.0(transitive)
- Removednode-opcua-variant@2.10.0(transitive)
Updatednode-opcua-factory@2.11.0
Updatednode-opcua-nodeid@2.11.0
Updatednode-opcua-types@2.11.0