Unsolved How to detect loss connectivity in QOpcUaClient
-
We are using the qt opc ua module with open62541 provider and have noticed that if I disconnect the network cable we would see the client log the following:
[2020-08-21 13:37:08.952 (UTC-0700)] error/client Inactivity for Subscription 2. [2020-08-21 13:37:18.953 (UTC-0700)] error/client Inactivity for Subscription 2. [2020-08-21 13:37:28.953 (UTC-0700)] error/client Inactivity for Subscription 2. [2020-08-21 13:37:38.954 (UTC-0700)] error/client Inactivity for Subscription 2. [2020-08-21 13:37:48.956 (UTC-0700)] error/client Inactivity for Subscription 2. [2020-08-21 13:37:58.956 (UTC-0700)] error/client Inactivity for Subscription 2. [2020-08-21 13:38:08.957 (UTC-0700)] error/client Inactivity for Subscription 2. [2020-08-21 13:38:18.958 (UTC-0700)] error/client Inactivity for Subscription 2. [2020-08-21 13:38:28.959 (UTC-0700)] error/client Inactivity for Subscription 2. [2020-08-21 13:38:38.959 (UTC-0700)] error/client Inactivity for Subscription 2.
and after a minute these messages start to show up
[2020-08-21 13:38:48.620 (UTC-0700)] info/client Received a ServiceFault response [2020-08-21 13:38:48.620 (UTC-0700)] info/client The ServiceResult has the StatusCode BadNoSubscription [2020-08-21 13:38:48.620 (UTC-0700)] info/client Received a ServiceFault response [2020-08-21 13:38:48.620 (UTC-0700)] info/client The ServiceResult has the StatusCode BadNoSubscription [2020-08-21 13:38:48.620 (UTC-0700)] info/client Received a ServiceFault response
However I don't get any state change signals or error change signals as I was hoping for.
https://doc-snapshots.qt.io/qtopcua/qopcuaclient.html
It makes sense that this support should be present. Does anyone have advise on what we've not properly configured?
Here is how we are linking up the signals:void stateChanged(QOpcUaClient::ClientState state) { vLogSys(LMT_INFO, TRUE, "Client state changed: %d", state); qInfo() << "Client state changed: " << state; ...
void errorChanged(QOpcUaClient::ClientError error) { vLogSys(LMT_INFO, TRUE, "Client error changed: %d", error); qInfo() << "Client error changed: " << error; }
QObject::connect(client, &QOpcUaClient::errorChanged, &errorChanged);
If i just shutdown the opcua server I do get a disconnect stateChanged event and on normal startup I get the connected stateChanged event. It is just physically disconnecting the cable that we are having trouble detecting as it never seems to enter the disconnected event. If we disconnect and reconnect the Ethernet cable for less than a minute (the session timeout period) the connection will reestablish and subscription updates will occur normally for the client. What would be ideal is after the 1 min timeout we eventually enter the disconnect state but that does not seem to happen. We have seen one of three things happen, a system crash, the disconnect event, system just reporting that BadNoSubscription but wo an expected disconnected event or error state change.
Our client is running the following stack:
ubuntu 18.04
qtbase 5.14.1
qtopcua 5.14.1
open62541 1.0
mbedtls 2.2.1