我是 OpcUA 的新手并使用 Open62541 v3.0 - rc2。
我正在尝试连接到 B&R 设备上的 OpcUA 服务器。
当我尝试连接到服务器(使用用户名和密码)时,我收到此消息"No suitable UserTokenPolicy found for the possible endpoints"
和此 return-value UA_STATUSCODE_BADINTERNALERROR
。
UA_StatusCode statusCode = UA_Client_connect_username(client,endpoint,"user","password");
与UAExpert 的设备连接正常。
阿联酋专家的日志打印以下消息:
安全策略:' http: //opcfoundation.org/UA/SecurityPolicy#None '
为什么我无法使用以下代码连接到服务器?
#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