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

QMqttSubscription is not invalidated upon disconnection

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.5.2
    • MQTT
    • None
    • Windows

    Description

      If the client specifies `setCleanSession(true)` (or, if the broker has a low-enough `persistent_client_expiration` value), a QMqttSubscription will not survive a disconnect + reconnect cycle, even though its status never changes.

       

      Since the subscription is owned by the QMqttClient (according to QMqttClient::subscribe() docs), I think that the QMqttClient should trigger something to transition the QMqttSubscription state to the "Error" state (or something).

       

      Please see the attached project.  As a work around, the manual "tear down subscription and recreate it" code block can be uncommented in helper.cpp.

       

      Steps:

      1) build
      2) run
      3) click anywhere in the app to trigger first-time-connection
      4) wait for 12 seconds or so (you should see messages saying published+received values)
      5) disable your wifi and wait until the app transitions to Disconnected state (takes ages - QtMqtt is not swift at noticing that the network has vanished - can this be fixed too?)
      6) enable your wifi, and then either wait 20s for the automatic reconnect, or click in the app
      7) wait for 12 seconds or so (but the bug is: this time we see published values, but no received values, unlike in step 4 where we see both increase)

       

      Tested on Windows 11 with Qt 6.5.2.

       

      Attachments

        1. CMakeLists.txt
          1 kB
        2. helper.cpp
          4 kB
        3. helper.h
          2 kB
        4. main.cpp
          0.4 kB
        5. Main.qml
          0.8 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            mkalinow Maurice Kalinowski
            chrisadams Christopher Adams
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes