Page 1 of 1

mbedTLS error with MQTT

Posted: Thu Feb 07, 2019 3:55 pm
by adam_ohara
I am working on a project that involves receiving a large number of messages to an MQTT topic in quick succession, as part of an OTA system. The messages are approximately 1kB in size, and are transmitted every second or so (the device requests the next message upon processing the current one). The approach works fine without TLS, but when I add mbedTLS into the mix I get the following:

Code: Select all


E (194719) esp-tls: write error :-27648:
E (194719) TRANS_SSL: esp_tls_conn_write error, errno=Success
E (194729) MQTT_CLIENT: Error write data or timeout, written len = -27648
E (194729) MQTT_CLIENT: Error to public data to topic=<removed>, qos=0
E (194739) OTA: Failed to request next page
E (194749) OTA: Failed to process new page
E (194909) esp-tls: read error :-80:
E (194909) TRANS_SSL: esp_tls_conn_read error, errno=Connection reset by peer
E (194909) MQTT_CLIENT: Read error or end of stream

I have tried sending larger messages less frequently (50kB). This does seem to reduce, but not eliminate, the problem. It appears to be the frequency at which messages are received that causes the issue.

This is using the MQTT module from commit bed50a93f of the esp-idf. Is this likely to be something that I am doing wrong, or a problem with the libraries?

Edit: Researching the error code (-27648 = -0x6C00) results in MBEDTLS_ERR_SSL_INTERNAL_ERROR, which isn't particularly helpful.

Re: mbedTLS error with MQTT

Posted: Fri Feb 08, 2019 7:54 am
by ESP_cermak
Hi Adam,

I see that idf version bed50a93f references https://github.com/espressif/esp-mqtt/c ... 5297626f36, which does not yet solve reception of multiple smaller messages in a single buffer, which might be your use case. Updating the idf would help.

Interesting is that you're saying it works ok without TLS (well maybe TLS causing delays so the TCP packets to "accumulate" multiple mqtt messages...)

Other than, current version of the MQTT library is not thread safe yet. So if you publish the data from a different task, it might not work as expected. An update of the library should be available soon.

Re: mbedTLS error with MQTT

Posted: Fri Nov 22, 2019 10:42 am
by ESP_cermak
Just a quick update on this old issue (might be useful for others with similar issues). Not sure what the root-cause was, but generally all these possible symptoms were solved:
* thread safety
* fragmenting out messages, receiving fragmented messages
* fragmenting on TLS layer (solved recently in https://github.com/espressif/esp-idf/co ... 7f362f93b1)

As for the description of the issue and the note that it worked without TLS assuming the actual issue might have been the last one, fixed recently.