arduino-mqtt: SSL not working properly disconnects after few seconds and never connects back

when i reboot my deivce the mqtt connects and after few second it gets disconnected and when it tried to reconnect it just throws the error

[E][ssl_client.cpp:33] handle_error(): UNKNOWN ERROR CODE (004C)
[E][ssl_client.cpp:35] handle_error(): MbedTLS message code: -76
[E][ssl_client.cpp:33] handle_error(): UNKNOWN ERROR CODE (004C)
[E][ssl_client.cpp:35] handle_error(): MbedTLS message code: -76

About this issue

  • Original URL
  • State: closed
  • Created 5 years ago
  • Comments: 16 (1 by maintainers)

Most upvoted comments

hola como están comunidad les comento que solucione ese problema de [E][ssl_client.cpp:33] _handle_error(): [data_to_read():270]: (-76) UNKNOWN ERROR CODE (004C) se debe que el puerto esta en disputa hay dos eventos que quieren el apropiarse al puerto y cuando el WiFiClientSecure no lo obtiene manda el mensaje UNKNOWN ERROR CODE (004C) mismo que significa Error al leer la información del socket como manda el link del compañero "clausqr " para ello se pueden usar un semaphremutex para hacer exclusion mutua y proteger el recurso. bueno mas nada espero y les sirva saludos a todos

I have the same problem using platformio and ESP32 Arduino.

Espressif32 => 1.9.0

Solved - leaving this here for others who stumble upon this

I came across this issue as well on my project, and after investigating further what was happening I found that invoking a mqtt publish from a separate task was causing the issue. My code was using both core’s and multiple tasks, and publishing from a separate task caused the issue. To resolve / workaround the issue I queued the message, then used the main loop to dequeue the messages and publish them.