ESP32 fails to connect to MQTT... Error Code = -4

Hi,
We have been working on sending some data on UBIDOTS using MQTT. We have been experiencing some issues related to connection to MQTT server with the following error:

Attempting MQTT connection…failed, rc=-4 try again in 3 seconds

Everything was working fine earlier. Suddenly, today it has started giving this error.

We have tried to connect ESP32 to different networks, but all in vain.

Please help.

Hello @divneet, according to the return code, it seems to be an error related to the credentials, as the connection is not going through

MQTT return code -4: Connection timeout.

Please remember that Ubidots’ MQTT broker endpoint is industrial.api.ubidots.com

Take a look at this article, as it might help you on getting a proper connection via MQTT on your ESP32 with Ubidots.

@divneet, after some testing and investigation, it looks like it’s a version issue with the library. Could you please try again but this time using this library?

I’ll be attentive to your response.

@Sebastian
Thanks for the reply.
We made MQTT broker endpoint changes to industrial.api.ubidots.com, and it worked.
Surprisingly, it is also working now for things.ubidots.com as well.
I believe there was MQTT server error for that day only.

I will also update the library, and get back to you soon.

Thanks for the support.