Mqtt Client reconnect

Hi.
I’m testing the mqtt client and in particular the auto reconnection.
I set automaticReconnectWithDefaultConfig () and when I deactivate the wifi of the android device, an event is generated in the addDisconnectedListener: a
ddDisconnectedListener java.net.UnknownHostException: Unable to resolve host “testmqtt.xxx.it”: No address associated with hostname
When I then turn the wifi back on, I would expect the mqtt to reconnect automatically, but I always get this error:

addDisconnectedListener CONNECT failed as CONNACK contained an Error Code: NOT_AUTHORIZED.

what can be the reason?
Thank you

I have found the problem. I have moved the
simpleAuth()
from
connectWith()
to
MqttClient.builder()

1 Like