Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-85422

QtOpcUA QML. After reconnection (connectToEndpoint after disconnectFromEndpoint) ValueNodes are not updated

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P2: Important
    • Resolution: Fixed
    • Affects Version/s: 5.15.0
    • Fix Version/s: 5.15.2, 5.15
    • Component/s: OpcUA
    • Labels:
      None
    • Platform/s:
      Windows

      Description

      Develop OPC UA Client with QML. Test with UA Demo server.

      After first endpoint discovery, QtOpcUa.Connection.connectToEndpoint works fine, ValueNodes are updating.

      But after disconnectFromEndpoint, and connectToEndpoint again, connection status is connected, but ValueNodes are not updating anymore.

      See the example code. After first start everything fine: status connected and value is updating. After click Disconnect button and Connect again - ValueNode doesn't update value from server anymore.

      import QtQuick 2.12
      import QtQuick.Window 2.12
      import QtQuick.Controls 2.3
      import QtOpcUa 5.15 as QtOpcUa
      
      Window {
          visible: true
          width: 640
          height: 480
          title: qsTr("Hello World")
      
          QtOpcUa.Connection {
              id: connection
              backend: "open62541"
              defaultConnection: true
          }
      
          QtOpcUa.ServerDiscovery {
              id: serverDiscovery
              discoveryUrl: "opc.tcp://127.0.0.1:48020"
              onServersChanged: {
                  if (!count)
                      return;
                  endpointDiscovery.serverUrl = at(0).discoveryUrls[0];
              }
          }
      
          QtOpcUa.EndpointDiscovery {
              id: endpointDiscovery
              onEndpointsChanged: {
                  if (!count)
                     return;
                  connection.connectToEndpoint(at(0));
              }
          }
      
          QtOpcUa.ValueNode {
              nodeId: QtOpcUa.NodeId {
                  identifier: "s=Demo.Dynamic.Scalar.String"
                  ns: "4"
              }
              id: demoString
          }
      
          Button {
              x: 14
              y: 13
              width: 112
              height: 40
              text: connection.connected ? "Disconnect" : "Connect"
              visible: true
              onClicked: {
                  if (connection.connected)
                      connection.disconnectFromEndpoint()
                  else
                      connection.connectToEndpoint(endpointDiscovery.at(0));
              }
          }
      
          Text {
              x: 14
              y: 68
              width: 346
              height: 28
              text: demoString.value
          }
      }
      

        Attachments

        For Gerrit Dashboard: QTBUG-85422
        # Subject Branch Project Status CR V

          Activity

            People

            Assignee:
            fmeerkoetter Frank Meerkötter
            Reporter:
            kirillfridman Kirill Fridman
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:

                Gerrit Reviews

                There is 1 open Gerrit change