I just bumped your user level away from "new user", see if you can post or create a new topic now.
Use opc.tcp://127.0.0.1:62541
as your endpoint URL. You were at least communicating with the server in that case. When you use "localhost" it seems you never connect at all. There must be something funny happening on Windows with localhost vs 127.0.0.1.
Alternatively, try setting the "Bind Addresses" setting for the Ignition OPC UA server to 0.0.0.0
. Remember to restart.
I get the more info by use of my own debug function:
#include <iostream>
#include <memory>
#include <open62541/client_config_default.h>
void debugLogger(void* context, UA_LogLevel level, UA_LogCategory category, const char* msg, va_list args);
int main()
{
UA_StatusCode status = UA_STATUSCODE_GOOD;
std::unique_ptr<UA_Client, decltype(&UA_Client_delete)> client(UA_Client_new(), UA_Client_delete);
UA_ClientConfig* cfg = UA_Client_getConfig(client.get());
cfg->logging->log = debugLogger;
status = UA_ClientConfig_setDefault(cfg);
if (status != UA_STATUSCODE_GOOD) {
std::cout << "StatusCode: " << UA_StatusCode_name(status) << "\n";
return EXIT_FAILURE;
}
#if 0
status = UA_Client_connect(client.get(), "opc.tcp://ATL-N0012.DataManag.local:53530/OPCUA/SimulationServer");
#else
status = UA_Client_connect(client.get(), "opc.tcp://localhost:62541/discovery");
#endif
if (status != UA_STATUSCODE_GOOD) {
std::cout << "StatusCode: " << UA_StatusCode_name(status) << "\n";
return EXIT_FAILURE;
}
return status == UA_STATUSCODE_GOOD ? EXIT_SUCCESS : EXIT_FAILURE;
}
void debugLogger(void* context, UA_LogLevel level, UA_LogCategory category, const char* msg, va_list args) {
const char* levelStr = "";
switch (level) {
case UA_LOGLEVEL_TRACE: levelStr = "TRACE"; break;
case UA_LOGLEVEL_DEBUG: levelStr = "DEBUG"; break;
case UA_LOGLEVEL_INFO: levelStr = "INFO"; break;
case UA_LOGLEVEL_WARNING: levelStr = "WARNING"; break;
case UA_LOGLEVEL_ERROR: levelStr = "ERROR"; break;
case UA_LOGLEVEL_FATAL: levelStr = "FATAL"; break;
}
const char* catStr = "";
switch (category) {
case UA_LOGCATEGORY_NETWORK:
catStr = "NETWORK";
break;
case UA_LOGCATEGORY_SECURECHANNEL:
catStr = "SECURECHANNEL";
break;
case UA_LOGCATEGORY_SESSION:
catStr = "SESSION";
break;
case UA_LOGCATEGORY_SERVER:
catStr = "SERVER";
break;
case UA_LOGCATEGORY_CLIENT:
catStr = "CLIENT";
break;
case UA_LOGCATEGORY_USERLAND:
catStr = "USERLAND";
break;
case UA_LOGCATEGORY_SECURITYPOLICY:
catStr = "SECURITYPOLICY";
break;
case UA_LOGCATEGORY_EVENTLOOP:
catStr = "EVENTLOOP";
break;
case UA_LOGCATEGORY_PUBSUB:
catStr = "PUBSUB";
break;
case UA_LOGCATEGORY_DISCOVERY:
catStr = "DISCOVERY";
break;
default:
catStr = "UNKNOWN";
break;
}
printf("[%s][%s] ", levelStr, catStr);
vprintf(msg, args);
printf("\n");
}
Ignition OPC server windows
Prosys:
Thanks a lot. All apps are running on windows platform. My client test app is compiled with Visual C++ 2022. It works with Prosys OPC UA simulator server, but doesn't with Ignition OPC UA server!
If I use the end point url 'opc.tcp://127.0.0.1:62541/discovery' instead of 'opc.tcp://localhost:62541/discovery', my client app works correctly.
This works, but it is strange to me. Ignition OPC UA server has a bug here.
You may think so, but you haven't supported that, IMNSHO.
Do a domain name lookup on localhost
in your environment. I bet it has been modified to not return 127.0.0.1
like it is supposed to.
Ok, try setting the "Bind Addresses" back to just localhost
, and then go modify the "Endpoint Addresses" setting to be <hostname>,<localhost>,localhost
. Remember to restart.
It would also be useful if you shared the output of the UaStackServer logger from the Ignition logs during the OPC UA module startup sequence. It looks something like this:
The Prosys monitor connects. Ignition's client connects. UaExpert connects.
if every other client and SDK can connect, but yours can't, maybe the bug isn't in the server...