hi,
If you running SYSTEM_THREAD(ENABLED)
you have to set 4-th parameter in your client initialization
MQTT client("sample.com", 1883, callback, true);
here from official example:
In this case even if your broker is not available the code will not block