mqttesp32

ESP32 IDF Problem running MQTT with TLS over WIFI MESH


I have 2 ESP32-S3 dev boards with the same software including mqtt5_cfg.broker.verification.certificate loaded. I am using the latest IDF ver 5.5.0

I am running MQTT5 over IDF WIFI Mesh.

If I configure MQTT to use the eclipse Mosquito broker over TCP on port 1883 everything works fine on both boards (MESH_ROOT and MESH_NODE)

But if I configure MQTT to use TLS on port 8883:

If I power off the MESH_ROOT board, the other board becomes the new MESH_ROOT and MQTT works fine on TLS now.

If I power up the other board, it becomes MESH_NODE and gets the TLS error.

See logs below.

Any ideas appreciated.

Connect MESH_ROOT

I (00:02:22.332) aMQTT: Pre esp_mqtt_client_init
I (00:02:22.334) aMQTT: mqtt5_cfg.task.priority: 0
I (00:02:22.335) aMQTT: mqtt5_cfg.outbox.limit: 0
I (00:02:22.336) aMQTT: mqtt5_cfg.buffer.size: 20480
I (00:02:22.337) aMQTT: mqtt5_cfg.buffer.out_size: 10240
I (00:02:22.338) aMQTT: Post esp_mqtt_client_init
I (00:02:22.339) aMQTT: Broker pre Connect
I (00:02:22.342) aMQTT: Other event id:7
I (00:02:22.348) aMQTT: Broker post connect
I (15224) wifi:<ba-add>idx:1 (ifx:0, 00:17:13:20:bd:74), tid:1, ssn:1, winSize:64
W (00:02:24.825) aMQTT: Broker connected
I (00:02:24.826) aLED: connectionStatus: 0
I (00:02:24.827) aEvent: queueEvent Device: 11 Node: 0, Event: 1
I (00:02:24.852) aMQTT: Resubscribe to our 6 Topics
I (00:02:24.859) aMQTT: Sent subscribe successful, Topic: SiteID/000048CA439B5D20/Pump/+/Command/#  msg_id: 1
I (00:02:24.883) aMQTT: Sent subscribe successful, Topic: SiteID/000048CA439B5D20/Probe/+/Command/#  msg_id: 2
I (00:02:24.893) aMQTT: Sent subscribe successful, Topic: SiteID/000048CA439B5D20/Pump/+/TransactionResponse  msg_id: 3
I (00:02:24.943) aMQTT: Sent subscribe successful, Topic: SiteID/000048CA439B5D20/EventResponse  msg_id: 4
I (00:02:24.958) aMQTT: Sent subscribe successful, Topic: SiteID/000048CA439B5D20/Command/#  msg_id: 5
I (00:02:24.979) aMQTT: Sent subscribe successful, Topic: SiteID/000048CA439B5D20/ConsoleCmd  msg_id: 6
I (00:02:25.002) aMQTT: SiteID/000048CA439B5D20/Pump/22/Status status=18/state=4
I (00:02:25.219) aMQTT: SiteID/000048CA439B5D20/Pump/23/Status status=18/state=4
I (00:02:25.234) aMQTT: MQTT_EVENT_SUBSCRIBED, msg_id=1  inFlightCounter: 0
I (00:02:25.444) aMQTT: SiteID/000048CA439B5D20/Pump/24/Status status=18/state=4
I (00:02:25.594) aMQTT: MQTT_EVENT_SUBSCRIBED, msg_id=2  inFlightCounter: 0
I (00:02:25.602) aMQTT: MQTT_EVENT_SUBSCRIBED, msg_id=3  inFlightCounter: 0
I (00:02:25.611) aMQTT: MQTT_EVENT_SUBSCRIBED, msg_id=4  inFlightCounter: 0
I (00:02:25.617) aMQTT: MQTT_EVENT_SUBSCRIBED, msg_id=5  inFlightCounter: 0
I (00:02:25.625) aMQTT: MQTT_EVENT_SUBSCRIBED, msg_id=6  inFlightCounter: 0

Connect MESH_NODE

I (00:00:08.467) aEvent: queueEvent Device: 9 Node: 0, Event: 24 10.0.0.2
W (00:00:08.469) aWifiMesh: MESH_NODE  Layer: 2  MAC: 48:ca:43:9b:53:d8  IP: 10.0.0.2
I (00:00:08.470) aWifiMesh: Network is: self organized
I (00:00:08.471) aWifiMesh: Mesh Root: 48:ca:43:9b:5d:20 is not fixed
I (00:00:08.473) aWifiMesh: Number of nodes: 1
I (00:00:08.474) aWifiMesh: Max layers: 4
I (00:00:08.475) aWifiMesh: Mesh Parent MAC: 48:ca:43:9b:5d:21  RSSI: -22  Channel: 1
I (00:00:08.477) aWifiMesh: Mesh routing Table records: 1   Record size: 6   Table size: 6
I (00:00:08.479) aWifiMesh:   MAC: 48:ca:43:9b:53:d8
I (00:00:09.314) aMQTT: Pre esp_mqtt_client_init
I (00:00:09.316) aMQTT: mqtt5_cfg.task.priority: 0
I (00:00:09.317) aMQTT: mqtt5_cfg.outbox.limit: 0
I (00:00:09.318) aMQTT: mqtt5_cfg.buffer.size: 20480
I (00:00:09.320) aMQTT: mqtt5_cfg.buffer.out_size: 10240
I (00:00:09.321) aMQTT: Post esp_mqtt_client_init
I (00:00:09.322) aMQTT: Broker pre Connect
I (00:00:09.330) aMQTT: Other event id:7
I (00:00:09.337) aMQTT: Broker post connect
W (00:00:13.119) aMQTT: Broker connected
I (00:00:13.120) aLED: connectionStatus: 0
I (00:00:13.121) aEvent: queueEvent Device: 11 Node: 0, Event: 1
I (14739) mesh: 5161<active>parent layer:1(node), channel:1, rssi:-22, assoc:0(cnx rssi threshold:-120)my_assoc:0
I (00:00:13.146) aMQTT: Resubscribe to our 6 Topics
I (00:00:13.169) aMQTT: Sent subscribe successful, Topic: SiteID/000048CA439B53D8/Pump/+/Command/#  msg_id: 1
I (00:00:13.179) aMQTT: Sent subscribe successful, Topic: SiteID/000048CA439B53D8/Probe/+/Command/#  msg_id: 2
I (00:00:13.191) aMQTT: Sent subscribe successful, Topic: SiteID/000048CA439B53D8/Pump/+/TransactionResponse  msg_id: 3
I (00:00:13.214) aMQTT: Sent subscribe successful, Topic: SiteID/000048CA439B53D8/EventResponse  msg_id: 4
I (00:00:13.222) aMQTT: Sent subscribe successful, Topic: SiteID/000048CA439B53D8/Command/#  msg_id: 5
I (00:00:13.234) aMQTT: Sent subscribe successful, Topic: SiteID/000048CA439B53D8/ConsoleCmd  msg_id: 6
I (00:00:13.559) aMQTT: MQTT_EVENT_SUBSCRIBED, msg_id=1  inFlightCounter: 0
E (00:00:14.067) esp-tls-mbedtls: read error :-0x7180
E (00:00:14.068) transport_base: esp_tls_conn_read error, errno=Connection already in progress
E (00:00:14.070) mqtt_client: esp_mqtt_handle_transport_read_error: transport_read() error: errno=119
E (00:00:14.072) aMQTT: MQTT_EVENT_ERROR
E (00:00:14.073) aMQTT: MQTT5 return code is 0
E (00:00:14.074) aMQTT: Last error reported from tls stack: 0x7180
E (00:00:14.076) aMQTT: Last errno string (Success)
E (00:00:14.077) mqtt_client: mqtt_process_receive: mqtt_message_receive() returned -2
W (00:00:14.090) aMQTT: Broker disconnected

Solution

  • It turned out I was being misled by a shortage of memory