-
Notifications
You must be signed in to change notification settings - Fork 58
Description
Describe the bug
during MQTTAgent_Publish, can happen that mqtt connection goes down (wifi is connected) and happen that the task calling the MQTTAgent_Publish is blocked waiting the Publish notification in xTaskNotifyWait( 0, 0, &ulNotification, portMAX_DELAY ).
if this xTaskNotifyWait is changed ot some timeout like xTaskNotifyWait( 0, 0, &ulNotification, pdMS_TO_TICKS(2000) );
I faced that the MQTTAgent_Publish fastly cause a crash as we can see in the screenshot .
who can avoid to wait portMAX_DELAY that block my task?
System information
- Hardware board: ESP32-S3 /ESP32
- IDE used: 5.2.2
- Operating System: Windows
- Code version: 69d1309 (after Use static buffer for OTA decoded buffer #103)
- Project/Demo: temp_sub_pub_and_led_control_demo
- If your project is a custom application, please add the relevant code snippet(s) in the section titled
"Code to reproduce bug".
Expected behavior
i'm expecting that the MQTTAgent_Publish exit for some timeout always.
presently i can set only a timeout: xCommandParams.blockTimeMs = waitTimeoutMsec; that seem to be not working if the publish is already queues.
if i try to avoid the notification xTaskNotifyWait( 0, 0, &ulNotification, portMAX_DELAY ) by commenting the line
the application fastly going in crash
there is a way to allow the Publish wait for a timeout only without crashing?
Screenshots or console output
If appropriate, please paste the console output/error log explaining the issue. If possible, include the call stack.
Steps to reproduce bug
Example:
1. "I am using project [ ... ], and have configured with [ ... ]"
2. "When run on [ ... ], I observed that [ ... ]"
Code to reproduce bug
xCommandContext.xTaskToNotify = xTaskGetCurrentTaskHandle();
xCommandContext.ulNotificationValue = ulPublishMessageId;
xCommandParams.blockTimeMs = waitTimeoutMsec;
xCommandParams.cmdCompleteCallback = prvPublishCommandCallback;
xCommandParams.pCmdCompleteCallbackContext = &xCommandContext;
/* To ensure ulNotification doesn't accidentally hold the expected value
* as it is to be checked against the value sent from the callback.. */
ulNotification = ~ulValueToNotify;
xCommandAdded = MQTTAgent_Publish( &xGlobalMqttAgentContext,
&xPublishInfo,
&xCommandParams );
configASSERT( xCommandAdded == MQTTSuccess );
/* For QoS 1 and 2, wait for the publish acknowledgment. For QoS0,
* wait for the publish to be sent. */
ESP_LOGI( TAG,
"Task %s waiting for publish %" PRIu32 " to complete.",
pcTaskName,
ulValueToNotify );
//prvWaitForCommandAcknowledgment( &ulNotification );
xTaskNotifyWait( 0, 0, &ulNotification, portMAX_DELAY );
// xCommandParams.cmdCompleteCallback = prvPublishCommandCallback;

Additional context
Include any additional context relevant to the issue here.


