MQTT reconnects indefinitely despite it manages to connect
<p>I'm using this library:</p>

<p><a href="https://github.com/fusesource/mqtt-client" rel="nofollow">https://github.com/fusesource/mqtt-client</a></p>

<p>With this options:</p>

<pre><code> MQTT mqtt = new MQTT();
 mqtt.setClientId(deviceId() + "-device");
 mqtt.setHost(getResources().getString(R.string.jms_uri));
 mqtt.setUserName(getResources().getString(R.string.jms_user));
 mqtt.setPassword(getResources().getString(R.string.jms_password));
 mqtt.setReconnectDelay(10000);
 mqtt.setReconnectDelayMax(60000);
 connection = mqtt.futureConnection();
 connection.connect().await(5, TimeUnit.SECONDS);
</code></pre>

<p>And sometimes (I cannot reproduce it) it seems to loose the connection and starts to reconnect "crazily". According to the JMS, it is managing to connect every time but, I don't know why, it keeps reconnecting (closing and starting a connection). The only thing I can do when this happens is to stop the app. In the meantime, the re-connection to the JMS is not fruitful as it is not able to receive any message.</p>

<p>It starts to reconnect all the time without waiting the ms I have set for the reconnection delay.</p>

<p>Any suggestion?</p>

<p>Thanks</p>