-
Notifications
You must be signed in to change notification settings - Fork 277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
No error in the case a QoS 1 message sending is timed out #119
Comments
Hi @vpetrigo, thanks for raising this. I'm not sure if I quite follow though. If I understand correctly, the problem you've identified is MQTT-C won't generate an error code if a QoS>0 message goes unacknowledged. Is that correct? If so, I believe that's true---no error code will be generated, and unacknowledged QoS>0 messages will just loop through timeout+resending. I'm struggling to see how the client could identify such an even though. Under this event (an unacknownledged QoS>0 message) the client is supposed to continue resending the message until it hears back from the broker. Therefore, if I've understood correctly, I think this event would have to be handled at the application level. Have I understood correctly? If not, could you clarify what error event is missed/what the expected way to handle it is? |
Hello @LiamBindle,
I try to provide as many details as I can right now:
So, I think it is a good idea to silently push a QoS = 0 messages into client's queue and forget about that, while it should not be the case for QoS > 0 messages. We have explicit configuration to be set - Handling of that case may be done on the app side, but it seems as duplicating responsibilities. We already have int rc = mqtt_publish(p_client, ...);
unsigned n_timeouts = p_client->number_of_timeouts;
unsigned start_timestamp = now();
while (now() - start_timestamp < response_timeout && p_client->number_of_timeouts ==n_timeouts)
{
rc = mqtt_sync(p_client, ...);
if (rc != MQTT_OK)
{
// handle error
}
} That leads us to wait for the whole defined Impact on keep-alive pings On of the options I see right now:
struct message_context {
uint16_t pid;
}
mqtt_publish(struct mqtt_client *client,
const char* topic_name,
const void* application_message,
size_t application_message_size,
uint8_t publish_flags
struct message_context *msg_ctx)
struct message_context on_the_fly_message;
// ...
void publish_ack_callback(..., uint16_t pid)
{
if (pid == on_the_fly_message.pid)
{
// set `ack_arrive` or notify awaiting task somehow
}
}
int rc = mqtt_publish(p_client, ..., &on_the_fly_message);
unsigned n_timeouts = p_client->number_of_timeouts;
unsigned start_timestamp = now();
while (now() - start_timestamp < response_timeout && ack_arrived)
{
rc = mqtt_sync(p_client, ...);
if (rc != MQTT_ACK_TIMEOUT_ERROR)
{
// handle error
}
} |
@vpetrigo I would be in favor of a PR that added:
I think those two would provide the necessary flexibility. What do you think? Would you be able to make a PR for this (or similar)? |
Closing due to inactivity. Please feel free to reopen. |
Up on this as it would be very useful to know if a QOS 1 message timed out. |
I'll reopen this. I'm happy to merge a PR that implements this. |
Hello everyone, |
@vpetrigo No worries at all---I totally understand. Same goes for me right now. When you have something ready, I'm happy to review and merge it. |
Hello,
I have met an issue that the library right now does not report an error if a message with QoS 1 (that should be valid for QoS 2 as well, but I have not checked that) sending meets command timeout.
As we can see there in the case of command timeout
__mqtt_send()
just marks a message to be resent in the future with no error indication to the caller.I would like to describe a case where it may introduce some problems:
Same effect may be observer with keep-alive pings that have not been confirmed with a PINGRESP from the broker.
Note 1
Right now it seems there are no way to explicitly wait for a message delivery with ACK. Potential workaround there is to call
mqtt_sync()
after a QoS 1 message send and wait forresponse_timeout
to see whetherclient.number_of_timeouts
increments or not.Current behaviour example
iptables
:iptables -A INPUT -s <broker IP> -j DROP
)MQTT_ERROR_SEND_BUFFER_IS_FULL
when a TX buffer is full of not delivered messages which may be handled as a signal for reconnection attempt to the brokerThe text was updated successfully, but these errors were encountered: