tbnobody / OpenDTU

Software for ESP32 to talk to Hoymiles/TSUN/Solenso Inverters
GNU General Public License v2.0
1.69k stars 471 forks source link

Support MQTT CA certificate validation for Azure Event Grid #2109

Open wohlfrom opened 2 days ago

wohlfrom commented 2 days ago

The use case is to publish MQTT events to the Azure Event Grid broker. You will get a MQTT server url in the form of *.germanywestcentral-1.ts.eventgrid.azure.net:8883. Only secure TLS connections are supported.

During the handshake the ESP produces are core dump and enters a reboot loop since the stack limit is reached for the MQTT task that is used for communicating to the broker. The last visible debug message on serial is

[  6550][V][ssl_client.cpp:269] start_ssl_client(): Performing the SSL/TLS handshake...

The default stack size is defined in the espMqttClient to

#define EMC_TASK_STACK_SIZE 5120

From debugging the required stack size seems to be 5268 bytes though. Therefore suggesting to increase the stack for the task to 6400 bytes which seems to be working fine with this broker (tested 24 hours).

This resolves #2110