|[paho-dev] Paho C: Reconnection callback|
I am working with Paho C library in asynchronous fashion and I would like to know the way of knowing that client has been reconnected. I will try to explain it deeper:
Suppose you connect the client to a broker with automaticReconnect option and the broker is restarted so the client lose its connection, calling to lostConenction callback. That is right, the user could know that the clients is now disconnected. The client would try to reconnect to broker. Once the broker is up again and the Paho client has successfully reconnected to it, there is no way to notify to the user that the client is connected again.
I expected that connectionCallback would be invoked again but not, since the function MQTTAsync_receiveThread(void* n) sets the connect callback to NULL to avoid call it again:
m->connect._onSuccess_ = NULL; /* don't accidentally call it again */
Is this the expected behavior? As user, I would like to know when my client has lost the connection but also when it recovers the connection again. I do not understand either why to clean connect.onSuccess callback to avoid calling it again but not connect.onFailure, allowing me (as user) to know every time reconnection fails but not when it success.
Just as a note, if the previous code line is commented I get the expected behavior.
Thank you so much for your tips.
Back to the top