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
Possibly this is more of a documentation change than a fix.
I have an instance where I need to publish a message to the server while my code is in the received message callback function. The mqtt_publish works fine but, if one calls mqtt_sync inside that function it will crash.
The text was updated successfully, but these errors were encountered:
@markrad Yeah, I think the documentation should say something about this (IIRC this came up once before). The receive callback is called in mqtt_sync() while the mutex is locked, so calls to mqtt_sync() (along with some other functions) is not permitted. The callback is moreso meant to be like an interrupt, in that it should contain pretty minimal logic and be run quick, but that isn't explicitly documented anywhere.
Thanks for opening. I'll update the docs accordingly (unless someone else wants to do it) when I get a chance.
I'm also facing this problem.
In the simple_subscriber example I add a mqtt_publish within the publish_callback function leaving the mqtt_sync call in the client_refresher thread. This causes a segmentation fault.
Somehow the first time I tried this it worked, but now it doesn't work anymore.
I saw the publish_callback is called by mqtt_sync after locking the mutex so a mqtt_publish within the publish_callback try to lock again the mutex causing the segmentation fault.
The only way I thought to get it working is to start a new thread from the publish_callback only with the aim to send a mqtt_publish.
May this be a solution?
Possibly this is more of a documentation change than a fix.
I have an instance where I need to publish a message to the server while my code is in the received message callback function. The mqtt_publish works fine but, if one calls mqtt_sync inside that function it will crash.
The text was updated successfully, but these errors were encountered: