I think there may be a bug in the SDK (or stack) related to the FindServers service:
If the UaClientSdk::ServiceSettings::callTimeout is put to 1000 msec, and there is no server running at the specified URL, then UaClientSdk::UaDiscovery::findServers sometimes crashes. It only seems to happen in Windows, not in Linux.
Here's a sample program to reproduce the crash:
Code: Select all
// discovery_crash.cpp
// STD
#include <iostream>
// SDK
#include "uabase/uaplatformlayer.h"
#include "uaclient/uaclientsdk.h"
#include "uaclient/uadiscovery.h"
int main(int /*argc*/, char* /*argv*/[])
{
// initialize the SDK
if(UaPlatformLayer::init() != 0)
{
std::cout << "The SDK could not be initialized!\n";
return 1;
}
UaClientSdk::UaDiscovery uaDiscovery;
UaClientSdk::ServiceSettings serviceSettings;
UaString url("opc.tcp://localhost:4841");
UaClientSdk::ClientSecurityInfo clientSecurityInfo;
UaApplicationDescriptions descriptions;
// put the callTimeout to 500 msec --> BadTimeout but no crashes
// put the callTimeout to 2000 msec --> BadCommunicationError but no crashes
// put the callTimeout to 1000 msec --> mostly BadTimeouts, sometimes BadCommunicationErrors, after a while: crash
serviceSettings.callTimeout = 1000;
while (true)
{
UaStatus discoveryStatus = uaDiscovery.findServers(
serviceSettings,
url,
clientSecurityInfo,
descriptions);
std::cout << "FindServers Status: " << discoveryStatus.toString().toUtf8() << "\n";
}
return 0;
}
Wim