diff options
author | Jannis Voelker <jannis.voelker@basyskom.com> | 2018-03-06 12:13:04 +0100 |
---|---|---|
committer | Jannis Völker <jannis.voelker@basyskom.com> | 2018-03-14 09:56:05 +0000 |
commit | d6cb340c24908212c694cf815899747b6e2b7531 (patch) | |
tree | 8b891c71d520ec87392119095b88ad1d90ed5e98 | |
parent | a7281ad15be2cd72f0e34f713db78fa2a4b944d2 (diff) |
Disable automatic reconnect in the uacpp backend
Open62541 and freeopcua report the disconnect in a signal and require
the user to reconnect manually, e. g. in the signal handler.
This patch disables the default auto reconnect in the uacpp session.
Change-Id: Ib032be5a0b8253f840003dc4806ed67d3026858e
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
-rw-r--r-- | src/plugins/opcua/uacpp/quacppbackend.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qopcuaclient/tst_client.cpp | 3 |
2 files changed, 5 insertions, 2 deletions
diff --git a/src/plugins/opcua/uacpp/quacppbackend.cpp b/src/plugins/opcua/uacpp/quacppbackend.cpp index 83038c5..dbf234e 100644 --- a/src/plugins/opcua/uacpp/quacppbackend.cpp +++ b/src/plugins/opcua/uacpp/quacppbackend.cpp @@ -73,7 +73,8 @@ UACppAsyncBackend::~UACppAsyncBackend() if (m_nativeSession) { if (m_nativeSession->isConnected() != OpcUa_False) { - qCWarning(QT_OPCUA_PLUGINS_UACPP) << "UACPP: Deleting backend while still connected"; + if (m_nativeSession->serverStatus() != UaClient::ConnectionErrorApiReconnect) + qCWarning(QT_OPCUA_PLUGINS_UACPP) << "UACPP: Deleting backend while still connected"; ServiceSettings serviceSettings; m_nativeSession->disconnect(serviceSettings, OpcUa_True); } @@ -180,6 +181,7 @@ void UACppAsyncBackend::connectToEndpoint(const QUrl &url) sessionConnectInfo.sProductUri = "urn:Qt:OpcUAClient"; sessionConnectInfo.sSessionName = sessionConnectInfo.sApplicationUri; sessionConnectInfo.applicationType = OpcUa_ApplicationType_Client; + sessionConnectInfo.bAutomaticReconnect = OpcUa_False; SessionSecurityInfo sessionSecurityInfo; if (url.userName().length()) { diff --git a/tests/auto/qopcuaclient/tst_client.cpp b/tests/auto/qopcuaclient/tst_client.cpp index 4fc9b42..ae736e8 100644 --- a/tests/auto/qopcuaclient/tst_client.cpp +++ b/tests/auto/qopcuaclient/tst_client.cpp @@ -2031,10 +2031,11 @@ void Tst_QOpcUaClient::connectionLost() stringNode->readAttributes(QOpcUa::NodeAttribute::BrowseName); readSpy.wait(); - stateSpy.wait(); + stateSpy.wait(10000); // uacpp and open62541 use a timeout of 5 seconds for service calls, better be safe. QCOMPARE(readSpy.size(), 1); QVERIFY(readSpy.at(0).at(0).value<QOpcUa::NodeAttributes>() & QOpcUa::NodeAttribute::BrowseName); QCOMPARE(stringNode->attributeError(QOpcUa::NodeAttribute::BrowseName), QOpcUa::UaStatusCode::BadConnectionClosed); + QCOMPARE(stateSpy.size(), 1); QCOMPARE(stateSpy.at(0).at(0).value<QOpcUaClient::ClientState>(), QOpcUaClient::ClientState::Disconnected); } |