public void connectionLost() throws MqttException {
  boolean reconnected=false;
synchronized (connLock) {
    while (!reconnected && !connLockNotified) {
      try {
        wmqttClient.connect();
        reconnected=true;
      }
 catch (      MqttException mqe) {
        if (userConnect) {
          throw mqe;
        }
      }
      try {
        connLock.wait(2000);
      }
 catch (      InterruptedException ie) {
      }
    }
    connLockNotified=false;
  }
  if (reconnected) {
    try {
      String requestTopic[]={REQ_TOPIC};
      wmqttClient.subscribe(requestTopic,subQoS);
    }
 catch (    MqttException e) {
      disconnectClient();
      destroyClient();
      throw e;
    }
  }
}

public void connectionLost ( ) throws MqttException { boolean reconnected = false ; synchronized ( connLock ) { while ( ! reconnected && ! connLockNotified ) { try { wmqttClient . connect ( ) ; reconnected = true ; } catch ( MqttException mqe ) { if ( userConnect ) { throw mqe ; } } try { connLock . wait ( 2000 ) ; } catch ( InterruptedException ie ) { } } connLockNotified = false ; } if ( reconnected ) { try { String requestTopic [ ] = { REQ_TOPIC } ; wmqttClient . subscribe ( requestTopic , subQoS ) ; } catch ( MqttException e ) { disconnectClient ( ) ; destroyClient ( ) ; throw e ; } } }
this reconnects to the broker and resubscribes in the event of the mqttv3 connection unexpectedly breaking .
