Skip to content

[MQTT] Stop QoS0 push from refreshing keepalive#263

Merged
popduke merged 1 commit into
apache:mainfrom
EverWang:codex/qos0-keepalive-idle
Jun 12, 2026
Merged

[MQTT] Stop QoS0 push from refreshing keepalive#263
popduke merged 1 commit into
apache:mainfrom
EverWang:codex/qos0-keepalive-idle

Conversation

@EverWang

Copy link
Copy Markdown
Contributor

Fixes #260
QoS0 outbound PUBLISH refreshes MQTT keepalive idle timer and delays LWT for half-open clients

Summary

Stop outbound QoS0 PUBLISH write success from refreshing the MQTT session keepalive activity timestamp.

Motivation

When a client becomes half-open or loses power, the broker may still keep sending QoS0 downstream PUBLISH packets to that connection. Previously, successful QoS0 downstream writes updated lastActiveAtNanos, which could postpone keepalive idle detection and delay LWT publication even though the client no longer sends MQTT packets.

Changes

  • Remove lastActiveAtNanos = sessionCtx.nanoTime() from the QoS0 downstream write-success path.
  • Add a regression test to verify QoS0 downstream PUBLISH does not refresh MQTT session keepalive.

Tests

.\mvnw.cmd -pl bifromq-mqtt/bifromq-mqtt-server -Dtest=MQTT3TransientSessionHandlerTest#qos0PubDoesNotRefreshSessionKeepAlive test
.\mvnw.cmd -pl bifromq-mqtt/bifromq-mqtt-server -Dtest=MQTT3TransientSessionHandlerTest test

@popduke popduke force-pushed the codex/qos0-keepalive-idle branch from f3a682c to 747f495 Compare June 11, 2026 09:48

@popduke popduke left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@popduke popduke merged commit 2405843 into apache:main Jun 12, 2026
6 checks passed
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.

QoS0 outbound PUBLISH refreshes MQTT keepalive idle timer and delays LWT for half-open clients

2 participants