Problem with MQTT Conection

Hello everyone. I am doing connection tests from an app in Android Studio (Java) and of all the connection attempts I make, in most of them I get the message “Connection with MQTT broker failed” (it rarely gives me connection established) and therefore I am not able to establish the connection with HiveMQ. I am attaching the code of my activity to see if someone knows what I am doing wrong.
My level in programming is low and therefore I have many doubts.

Sorry, I forgot the second picture of the code.

Hi @Juanma ,

You indicated:

So in some cases, your code establishes the connection successfully, it does not fail every time, could you please confirm that for us?

If that is correct, did you already try using a random client ID instead of using the same client ID movi1 every time?

Dasha from HiveMQ team