MQTT client.isConnected() always returns true

Hi,
try this one:

and consider to use millis() instead of any long delay() like this: