TGViewer
Находки в опенсорсе: Python Находки в опенсорсе: Python @opensource_findings_python · 1.06K subscribers
Post #283 496
🚀 New issue to faststream-community/zMQTT by @borisalekseev
📝 Add Last Will support to the public MQTTClient API (#45)


Problem

zmqtt already implements MQTT Last Will at the packet/codec level, but it
cannot be configured through the public high-level client API.

Currently:

Will and WillProperties are only available through private
 zmqtt._internal modules;
MQTTClient and create_client() do not accept a will= argument;
MQTTClient._connect() builds every CONNECT packet without a Will.

As a result, users and frameworks built on the public zmqtt.MQTTClient API,
including FastStream, cannot configure an MQTT Last Will without depending on
private implementation details.

Proposed API

from zmqtt import MQTTClient, QoS, Will, WillProperties

will = Will(
topic="devices/device-42/status",
payload=b"offline",
qos=QoS.AT_LEAST_ONCE,
retain=True,
properties=WillProperties(
will_delay_interval=10,
content_type="text/plain",
),
)

client = MQTTClient(
"broker.example.com",
version="5.0",
will=will,
)

For MQTT 3.1.1, the same Will type should be usable without
WillProperties.

Scope
• Export Will and WillProperties from the top-level zmqtt package.
• Add will: Will | None = None to MQTTClient.
• Add the same argument to create_client() and all of its typed overloads.
• Store the configured Will and pass it to every Connect packet created by
 the client.
• Preserve the same Will configuration when the client reconnects after an
 established connection is lost.
• Reject MQTT 5.0 Will properties on MQTT 3.1.1 with a clear error consistent
 with other version-specific options.
• Keep the current behavior unchanged when will=None.

Tests

The tests should exercise the public client path rather than only the existing
packet codec:

• MQTT 3.1.1: construct MQTTClient(..., will=...), decode the emitted
 CONNECT, and verify the Will topic, payload, QoS, and retain flag.
• MQTT 5.0: verify the same fields together with WillProperties.
• Simulate will receiving of second client when the first reconnected unexpectedly

Tests should test public behaviour with real broker instead internals testing and avoid monkey patching.


#enhancement #good_first_issue #faststream #zmqtt
sent via relator
  • 🔥 4
More from @opensource_findings_python
  1. Sep 23, 2026🚀 New issue to ag2ai/faststream by @IvanKirpichnikov 📝 Feature: Implementation of the `A…
  2. Sep 22, 2026🚀 New issue to faststream-community/zMQTT by @borisalekseev 📝 Mark flaky Artemis test xf…
  3. Sep 17, 2026Помните про https://github.com/ozeranskii/httptap? Я писал о нем давно еще - > тут. Наклеп…
  4. Sep 15, 2026🚀 New issue to wemake-services/django-modern-rest by @sobolevn 📝 `test_custom_union_form…
  5. Sep 13, 2026🚀 New issue to wemake-services/django-modern-rest by @milssky 📝 Changes in benchmarking…
  6. Sep 13, 2026🚀 New issue to wemake-services/django-modern-rest by @sobolevn 📝 Fix `operation_id` defa…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →