Uploaded image for project: 'ActiveMQ Artemis'
  1. ActiveMQ Artemis
  2. ARTEMIS-3851

MQTT subscription queues exist after restart despite CleanSession=1

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Major
    • Resolution: Fixed
    • None
    • 2.24.0
    • None
    • None

    Description

      MQTT subscription queues are not cleaned up if the broker goes down while the consumer is connected.

      To reproduce the issue:

      1. Run AMQ broker with standard configuration (addresses and queues are auto-created)
      2. Run a MQTT consumer connecting to the target topic with CleanSession=true. At this point a subscription queue will be created on the address for the MQTT topic.
      3. Run a MQTT producer sending messages into the target topic.
      4. Since the producer is running, the consumer is receiving the messages.
      5. Shutdown AMQ (it can be done gracefully or by killing -9 it).
      6. Stop the MQTT producer.
      7. Stop the MQTT consumer
      8. Start the broker. After it is restarted, the old queue associated to the MQTT consumer is still there and it's not deleted.
      9. Run again the MQTT producer. The broker continues enqueuing messages into the old subscription queue.
      10. Stop the MQTT producer. The queue stops growing but it's still there with messages inside.

      The MQTT 3.1.1 specification states in section 3.1.2.4:

      If CleanSession is set to 1, the Client and Server MUST discard any previous Session and start a new one. This Session lasts as long as the Network Connection. State data associated with this Session MUST NOT be reused in any subsequent Session [MQTT-3.1.2-6].

      When the broker is stopped the network connection is terminated so the session's state data (including any messages for any subscriptions) should be removed.

      To be clear, this works differently in MQTT 5 where CleanSession became CleanStart and session expiry interval was added.

      Attachments

        Issue Links

          Activity

            People

              jbertram Justin Bertram
              jbertram Justin Bertram
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Time Tracking

                  Estimated:
                  Original Estimate - Not Specified
                  Not Specified
                  Remaining:
                  Remaining Estimate - 0h
                  0h
                  Logged:
                  Time Spent - 0.5h
                  0.5h