我是OpcUA新手,使用Open62541 v3.0-rc2。
我正试图连接到B&R设备上的OpcUA服务器。
当我试图连接到服务器(用户名和密码)时,我会得到这个消息"No suitable UserTokenPolicy found for the possible endpoints"和这个返回值UA_STATUSCODE_BADINTERNALERROR。
UA_StatusCode statusCode = UA_Client_connect_username(client,endpoint,"user","password");与UAExpert连接到设备的连接正在正常工作。
UAExpert的日志输出以下消息:
安全策略:“http://opcfoundation.org/UA/SecurityPolicy#None”
连接-UA中的设置-专家:

为什么我不能用下面的代码连接到服务器?
#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发布于 2018-08-07 06:44:22
请参阅“Open62541 GitHub”杂志:“用给定的用户名和密码连接到选定的服务器”
https://stackoverflow.com/questions/51653873
复制相似问题