Skip to content

Commit

Permalink
remove unwanted message when requestHandle is wrong
Browse files Browse the repository at this point in the history
  - some old third-party OPCUA Server based on OPCUA 1.0.2
    may return a incorrect requestHandle (0x00) in OpcuaSecureChannelRequest
    We should not display a warning message in this case as this is not
    harmful for the communication.
  • Loading branch information
erossignon committed May 16, 2021
1 parent 8817c9b commit f1f6ad7
Showing 1 changed file with 25 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -742,25 +742,31 @@ export class ClientSecureChannelLayer extends EventEmitter {
if (response.responseHeader.requestHandle !== request.requestHeader.requestHandle) {
const expected = request.requestHeader.requestHandle;
const actual = response.responseHeader.requestHandle;
const moreInfo = "Request= " + request.schema.name + " Response = " + response.schema.name;

const message =
" WARNING SERVER responseHeader.requestHandle is invalid" +
": expecting 0x" +
expected.toString(16) +
"(" +
expected +
")" +
" but got 0x" +
actual.toString(16) +
"(" +
actual +
")" +
" ";

debugLog(chalk.red.bold(message), chalk.yellow(moreInfo));
console.log(chalk.red.bold(message), chalk.yellow(moreInfo));
console.log(request.toString());

if (actual !== 0x0) {
// note some old OPCUA Server, like siemens with OPCUA 1.2 may send 0x00 as a
// requestHandle, this is not harmful. THis happened with OpenSecureChannelRequest
// so we only display the warning message if we have a real random discrepancy between the two requestHandle.
const moreInfo = "Request= " + request.schema.name + " Response = " + response.schema.name;

const message =
" WARNING SERVER responseHeader.requestHandle is invalid" +
": expecting 0x" +
expected.toString(16) +
"(" +
expected +
")" +
" but got 0x" +
actual.toString(16) +
"(" +
actual +
")" +
" ";

debugLog(chalk.red.bold(message), chalk.yellow(moreInfo));
warningLog(chalk.red.bold(message), chalk.yellow(moreInfo));
warningLog(request.toString());
}
}

requestData.response = response;
Expand Down

0 comments on commit f1f6ad7

Please sign in to comment.