Skip to content

Do not decrease inflight messages on PUBREL#884

Open
rubenbaer wants to merge 1 commit into
eclipse-paho:masterfrom
rubenbaer:fix/805
Open

Do not decrease inflight messages on PUBREL#884
rubenbaer wants to merge 1 commit into
eclipse-paho:masterfrom
rubenbaer:fix/805

Conversation

@rubenbaer

Copy link
Copy Markdown

When a QoS 2 message is received, the inflight messages was decremented on PUBREL. But the inflight messages must be a count of sent but not received messages. This yielded a negative inflight count for QoS 2 messages.

This change removes this decrement and fixes #805.

When a QoS 2 message is received, the inflight messages was decremented
on `PUBREL`. But the inflight messages must be a count of sent but not
received messages. This yielded a negative inflight count for QoS 2
messages.

This change removes this decrement and fixes eclipse-paho#805.

Signed-off-by: Ruben Bär <ruben@baer.sh>
@rubenbaer rubenbaer changed the title Do not decreate inflight messages on PUBREL Do not decrease inflight messages on PUBREL Mar 6, 2025
JamesParrott added a commit to JamesParrott/paho.mqtt.python that referenced this pull request Jun 16, 2026
@JamesParrott

JamesParrott commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

Hi Ruben, thanks for the PR. Sorry it's been over a year for a response.

The PR is super simple, and I can reproduce the original bug. I also confirm this PR fixes it, and that nothing breaks for QoS 0 and QoS 1 published messages. @PierreF Once this is rebased on to master, and passes the checks, it should be merged.

The original code looks straight forward - self.max_inflight_messages_set is a cap on the number of messages being published at once, and self._inflight_messages counts them.

It looks to me like there's nothing more to it, than the original author of the QoS 2 code adding another decrement to Client._handle_pubrel, being unaware that the decrement would already be done in `Client._handle_pubackcomp (as for QoS 1 messages, but which is also called on PUBCOMP for QoS 2).

Discussions on the original PR that added this decrement, were more concerned by other matters, that were perhaps more pressing at the time. Perhaps that PR's author simply forgot about the original decrement they added 2 years earlier

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Negative inflight messages counter with QoS 2 for subscribe and publish

2 participants