我正在使用节点OPC-UA客户端并出现以下错误
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)
我已经将此opc UCA(https://github.com/node-opcua/node-opcua)用于其他ocpUA服务器,并且它们工作正常。
UserTokenPolicy令牌似乎有问题,但是默认情况下它不是应该匿名登录吗? 可能还有其他问题吗?
请注意,它可与prosys opcua客户端一起使用。
答案 0 :(得分:0)
看起来UserIdentityTokenType = 4是not supported by node-opcua yet ...
const EnumUserIdentityTokenType_Schema = {
name: "EnumUserIdentityTokenType",
enumValues: {
ANONYMOUS: 0,
USERNAME: 1,
CERTIFICATE: 2,
ISSUEDTOKEN: 3
}
};
OPC规范1.04也仅指定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>
请在https://github.com/node-opcua/node-opcua中提出问题,并提供详细说明以重现此行为