C++ 连接到OpcUA服务器失败,原因是;“没有合适的用户令牌策略”;
我是OpcUA新手,使用Open62541 v3.0-rc2 我正在尝试连接到B&R设备上的OpcUA服务器 当我尝试连接到服务器(使用用户名和密码)时,我收到以下消息C++ 连接到OpcUA服务器失败,原因是;“没有合适的用户令牌策略”;,c++,opc-ua,open62541,C++,Opc Ua,Open62541,我是OpcUA新手,使用Open62541 v3.0-rc2 我正在尝试连接到B&R设备上的OpcUA服务器 当我尝试连接到服务器(使用用户名和密码)时,我收到以下消息“找不到适用于可能端点的合适的UserTokenPolicy”,并且返回值UA\U STATUSCODE\U BADINTERNALERROR UA_StatusCode statusCode = UA_Client_connect_username(client,endpoint,"user","password"); 与设备
“找不到适用于可能端点的合适的UserTokenPolicy”
,并且返回值UA\U STATUSCODE\U BADINTERNALERROR
UA_StatusCode statusCode = UA_Client_connect_username(client,endpoint,"user","password");
与设备的UAExpert连接工作正常
UAExpert的日志打印以下消息:
安全策略:“”
UA Expert中的连接设置:
为什么我不能用以下代码连接到服务器
#include "open62541.h"
UA_Logger logger = UA_Log_Stdout;
int main(void) {
const char* endpoint = "opc.tcp://br-automation:4840";
UA_ClientConfig config = UA_ClientConfig_default;
UA_Client *client = UA_Client_new(config);
UA_StatusCode statusCode = UA_Client_connect_username(client,endpoint,"user","password");
if(statusCode != UA_STATUSCODE_GOOD){
UA_LOG_ERROR(logger, UA_LOGCATEGORY_CLIENT, "Not connected. Got StatusCode 0x%X",statusCode);
}
else{
UA_LOG_INFO(logger,UA_LOGCATEGORY_CLIENT,"Connected");
}
UA_Client_delete(client);
return statusCode;
}
UA_Client_getEndpoints()给出以下结果:
7 endpoints found
URL of endpoint 0 is opc.tcp://br-automation:4840 Security-Policy: http://opcfoundation.org/UA/SecurityPolicy#None Security-Mode: 1
UserTokenType 1
UserTokenType 1
URL of endpoint 1 is opc.tcp://br-automation:4840 Security-Policy: http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15 Security-Mode: 2
UserTokenType 1
UserTokenType 1
URL of endpoint 2 is opc.tcp://br-automation:4840 Security-Policy: http://opcfoundation.org/UA/SecurityPolicy#Basic128Rsa15 Security-Mode: 3
UserTokenType 1
UserTokenType 1
URL of endpoint 3 is opc.tcp://br-automation:4840 Security-Policy: http://opcfoundation.org/UA/SecurityPolicy#Basic256 Security-Mode: 2
UserTokenType 1
UserTokenType 1
URL of endpoint 4 is opc.tcp://br-automation:4840 Security-Policy: http://opcfoundation.org/UA/SecurityPolicy#Basic256 Security-Mode: 3
UserTokenType 1
UserTokenType 1
URL of endpoint 5 is opc.tcp://br-automation:4840 Security-Policy: http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256 Security-Mode: 2
UserTokenType 1
UserTokenType 1
URL of endpoint 6 is opc.tcp://br-automation:4840 Security-Policy: http://opcfoundation.org/UA/SecurityPolicy#Basic256Sha256 Security-Mode: 3
UserTokenType 1
UserTokenType 1
请参阅此Open62541 GitHub问题: