I need some guidance with connection to the server process

20 views
Skip to first unread message

Miguel Gimenez

unread,
Feb 16, 2026, 4:15:10 PM (12 days ago) Feb 16
to open62541
Hello

I am creating a client application with open62541 v1.3.5. I have been checking the command line examples and I think I understand them, but I have problems with connections. Most probably I am misunderstanding the process.

My steps are:
- Find endpoints in the server. I get two endpoints, one with security mode None and security policy None and the other with security mode Sign and Encrypt and policy BasicSha256Rsa. In both endpoints TokenTypes are Anonymous and User/password (no X509 or Issued Token)
- The user selects one endpoint. Now I let the user select if he wants to connect anonymously or using user/password, and with the second endpoint I ask the user also for the client certificate and private key file.
- Anonymous connection works with the None/None endpoint, but User/password does not.
- If the selected endpoint security mode is Sign and Encrypt I call UA_ClientConfig_setDefaultEncryption() with the certificates, and then I call UA_Client_connect() or UA_Client_connectUsername(), depending if anonymous or user/password mode is selected. None work.

I have activated Trace logging, but I am now on another computer so I do not have the exact errors at hand.

My code:
    m_client = UA_Client_new();
    UA_ClientConfig* config = UA_Client_getConfig(m_client);
    UA_ClientConfig_setDefault(config);
    // Set message mode and security policy Uri depending on selected endpoint
    config->securityMode = (UA_MessageSecurityMode)m_serverInfo.SecurityMode;
    UA_String_clear(&config->securityPolicyUri);
    config->securityPolicyUri = UA_String_fromChars(m_serverInfo.SecurityPolicyUri.c_str());
if (config->securityMode > UA_MESSAGESECURITYMODE_NONE)
    UA_ClientConfig_setDefaultEncryption(config, clientCertificate, privateClientKey, NULL, 0, NULL, 0);
if (Anonymous)
    UA_Client_connect(m_client, m_serverInfo.Url);
else
    UA_Client_connectUsername(m_client, m_serverInfo.Url, User, Password);

TIA

Mathias Obetzhauser

unread,
Feb 17, 2026, 3:48:24 AM (11 days ago) Feb 17
to open62541
Hey, 

did you try the examples? 

Why are you using an old version and not the latest release of 1.4 or 1.5?


Greets
Mathias 

Miguel Gimenez

unread,
Feb 17, 2026, 8:45:58 AM (11 days ago) Feb 17
to open62541
El martes, 17 de febrero de 2026 a las 9:48:24 UTC+1, Mathias Obetzhauser escribió:
Hey, 

did you try the examples? 

The examples assume you know what the server needs, I try to extract the information from the endpoints so the user can choose only valid combinations.
 

Why are you using an old version and not the latest release of 1.4 or 1.5?

It was the current version when I started the project (OPC-UA is a small part of it); New versions have grown way too big (from 5 MB to 16 MB) and gave me some compilation problems in a quick test. I will give them a try, but I need to finish the project as soon as possible.
 
Reply all
Reply to author
Forward
0 new messages