1

I am using node OPC-UA client and getting following error

Error: cannot  coerce value=4 to Enum
at _decode_enumeration (/Users/xxx/apps/node-opcua-sample/node_modules/node-opcua-factory/src/factories_enumerations.js:52:23)
at UserTokenPolicy.decode (/Users/xxx/apps/node-opcua-sample/node_modules/node-opcua-service-endpoints/_generated_/_auto_generated_UserTokenPolicy.js:139:22)
at /Users/xxx/apps/node-opcua-sample/node_modules/node-opcua-service-endpoints/_generated_/_auto_generated_EndpointDescription.js:181:12
at exports.decodeArray (/Users/xxx/apps/node-opcua-sample/node_modules/node-opcua-basic-types/src/array.js:40:18)
at EndpointDescription.decode (/Users/xxx/apps/node-opcua-sample/node_modules/node-opcua-service-endpoints/_generated_/_auto_generated_EndpointDescription.js:179:31)
at /Users/xxx/apps/node-opcua-sample/node_modules/node-opcua-service-endpoints/_generated_/_auto_generated_GetEndpointsResponse.js:105:12
at exports.decodeArray (/Users/xxx/apps/node-opcua-sample/node_modules/node-opcua-basic-types/src/array.js:40:18)
at GetEndpointsResponse.decode (/Users/xxx/apps/node-opcua-sample/node_modules/node-opcua-service-endpoints/_generated_/_auto_generated_GetEndpointsResponse.js:103:22)
at MessageBuilder._safe_decode_message_body (/Users/xxx/apps/node-opcua-sample/node_modules/node-opcua-secure-channel/src/message_builder.js:403:20)
at MessageBuilder._decode_message_body (/Users/xxx/apps/node-opcua-sample/node_modules/node-opcua-secure-channel/src/message_builder.js:450:18)

I have been using this opc UCA (https://github.com/node-opcua/node-opcua) for other ocpUA server and they are working fine.

It seems a problem with UserTokenPolicy token, but isn't it should log in anonymous by default? What could be other issues?

Note it works with prosys opcua client.

Tranquillity
  • 237
  • 2
  • 9

1 Answers1

1

It looks like UserIdentityTokenType = 4 is not supported by node-opcua yet ...

const EnumUserIdentityTokenType_Schema = {
  name: "EnumUserIdentityTokenType",
  enumValues: {
    ANONYMOUS: 0,
    USERNAME: 1,
    CERTIFICATE: 2,
    ISSUEDTOKEN: 3
  }
};

OPC Specification 1.04 specifies also only 4 possible values from 0 to 3

<opc:EnumeratedType Name="UserTokenType" LengthInBits="32">
   <opc:Documentation>The possible user token types. 
   </opc:Documentation>
  <opc:EnumeratedValue Name="Anonymous" Value="0" />
  <opc:EnumeratedValue Name="UserName" Value="1" />
  <opc:EnumeratedValue Name="Certificate" Value="2" />
  <opc:EnumeratedValue Name="IssuedToken" Value="3" />
</opc:EnumeratedType>

Please raise an issue in https://github.com/node-opcua/node-opcua and provide detailed instruction to reproduce the behavior

Etienne
  • 16,249
  • 3
  • 26
  • 31