fusesource / mqtt-client

A Java MQTT Client
http://mqtt-client.fusesource.org/
Apache License 2.0
1.27k stars 369 forks source link

Inner mqtt is not accessible in the CallbackConnection after it's created #75

Open sxam opened 7 years ago

sxam commented 7 years ago

If I create a CallbackConnection using callbackConnection() method of MQTT class, it creates inner MQTT using "return new CallbackConnection(new MQTT(this))" . But the problem is that later on I don't have an access to it. And I need it in the following scenario:

I try to do connect that fails. If I see the "Could not connect: CONNECTION_REFUSED_NOT_AUTHORIZED" message, I don't want to connect anymore. So I tried to use mqtt.setConnectAttemptsMax(1); for it to affect the decision made by CallbackConnection in the onFailure method in tryReconnect checks ( "if(!CallbackConnection.this.disconnected && this.tryReconnect())" ) . But it seems that mqtt object I have at that point has got nothing to do with mqtt object CallbackConnection has, so it does nothing. As a bypass I currently try to play with "connection.suspend(); connection.kill" methods.