You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hi,
The API aws_iot_mqtt_subscribe() is used to subscribe some topic, and its 2nd parameter is the topic name, but I found that if I define topic name in stack, like this
voidtest(AWS_IoT_Client*client)
{
chartopic_name[128];
IoT_Error_trc=FAILURE;
memset(topic_name, 0, sizeof(topic_name));
strcpy(topic_name, "$aws/things/MyIoTButton/shadow/update/delta");
rc=aws_iot_mqtt_subscribe(client, topic_name, strlen(topic_len), xxx, xxx);
/// rc == SUCCESS, but xxx_cb will not be called when the topic is published at most time
}
Then, even thought its return code indicates SUCCESS, there is a great possibility that xxx_cb will not be called when the topic is published.
You are correct, this is an issue. Thank you very much for reporting it!
The problem comes from here:
in aws_iot_mqtt_client_subscribe.c, in _aws_iot_mqtt_internal_subscribe:
pClient->clientData.messageHandlers[indexOfFreeMessageHandler].topicName =
pTopicName;
It is passing a pointer fro stack to the message handler. That is what is causing the issue.
Regards,
We added a note in the documentation about stack parameters needing to remain in scope during an API call, #175. A true fix to this problem (copying parameters) isn't planned at this time. Closing issue.
Hi,
The API
aws_iot_mqtt_subscribe()
is used to subscribe some topic, and its 2nd parameter is the topic name, but I found that if I define topic name in stack, like thisThen, even thought its return code indicates SUCCESS, there is a great possibility that
xxx_cb
will not be called when the topic is published.But If I define topic name like this,
The
xxx_cb
will always be called when the topic is published.I think its not reasonable,
The text was updated successfully, but these errors were encountered: