im new to opc but need to connect with a server.
my colleague told me the server is no Security Policy and Certificate, just a username and password, he is not familiar with this too.
the result is :
enter image description here
And i do connect with the server by UaExpert:
enter image description here
enter image description here
there is my code:
#include "open62541.h"
#include "ros/ros.h"
#include <iostream>
int main() {
UA_Client *client = UA_Client_new();
UA_ClientConfig *cc = UA_Client_getConfig(client);
UA_ClientConfig_setDefault(cc);
cc->securityMode = UA_MESSAGESECURITYMODE_NONE;
const char* serverurl = "opc.tcp://server_ip";
const char* username = "username";
const char* password = "123";
UA_StatusCode retval = UA_Client_connectUsername(client, serverurl, username, password);
if(retval != UA_STATUSCODE_GOOD) {
UA_Client_delete(client);
return EXIT_FAILURE;
}
UA_LOG_INFO(UA_Log_Stdout, UA_LOGCATEGORY_USERLAND, "Connected!");
UA_Client_disconnect(client);
UA_Client_delete(client);
return retval == UA_STATUSCODE_GOOD ? EXIT_SUCCESS : EXIT_FAILURE;
}
i cant find a solution, so i ask the question
thanks
New contributor
DaNilsoN is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.