Uploaded image for project: 'ActiveMQ Classic'
  1. ActiveMQ Classic
  2. AMQ-5385

MQTT Link Stealing fails when client reconnects more than once

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 5.11.0
    • 5.11.0
    • MQTT
    • None

    Description

      Modified existing JUnit test case to re-connect with the same clientid a second time. Existing Test case tried once, which succeeded.
      When client reconnects the second time (third connection attempt with the same clientid), link stealing does not happen.

      Following is the modified test case.

          @Test(timeout = 60 * 1000)
          public void testDuplicateClientId() throws Exception {
              // test link stealing enabled by default
              final String clientId = "duplicateClient";
              MQTT mqtt = createMQTTConnection(clientId, false);
              mqtt.setKeepAlive((short) 2);
              final BlockingConnection connection = mqtt.blockingConnection();
              connection.connect();
              final String TOPICA = "TopicA";
              connection.publish(TOPICA, TOPICA.getBytes(), QoS.EXACTLY_ONCE, true);
       
              MQTT mqtt1 = createMQTTConnection(clientId, false);
              mqtt1.setKeepAlive((short) 2);
              final BlockingConnection connection1 = mqtt1.blockingConnection();
              connection1.connect();
       
              assertTrue("Duplicate client disconnected", Wait.waitFor(new Wait.Condition() {
                  @Override
                  public boolean isSatisified() throws Exception {
                      return connection1.isConnected();
                  }
              }));
       
              assertTrue("Old client still connected", Wait.waitFor(new Wait.Condition() {
                  @Override
                  public boolean isSatisified() throws Exception {
                      return !connection.isConnected();
                  }
              }));
       
              MQTT mqtt2 = createMQTTConnection(clientId, false);
              mqtt2.setKeepAlive((short) 2);
              final BlockingConnection connection4 = mqtt2.blockingConnection();
              connection4.connect();
       
              assertTrue("Old client still connected", Wait.waitFor(new Wait.Condition() {
                  @Override
                  public boolean isSatisified() throws Exception {
                      return !connection1.isConnected();
                  }
              }));
             
              assertTrue("Duplicate client disconnected", Wait.waitFor(new Wait.Condition() {
                  @Override
                  public boolean isSatisified() throws Exception {
                      return connection4.isConnected();
                  }
              }));
       
              connection4.disconnect();
      }
      

      Attachments

        Activity

          People

            tabish Timothy A. Bish
            workanandr AR
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: