Add note on always subscribing to the MQTT broker when topics are shared (#88159)

Add note on always subscribing
This commit is contained in:
Jan Bouwhuis 2023-02-15 10:46:57 +01:00 committed by GitHub
parent a1b7842df2
commit 09b509da94
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -565,6 +565,18 @@ class MQTT:
) -> None:
"""Perform MQTT client subscriptions."""
# Section 3.3.1.3 in the specification:
# http://docs.oasis-open.org/mqtt/mqtt/v3.1.1/os/mqtt-v3.1.1-os.html
# When sending a PUBLISH Packet to a Client the Server MUST
# set the RETAIN flag to 1 if a message is sent as a result of a
# new subscription being made by a Client [MQTT-3.3.1-8].
# It MUST set the RETAIN flag to 0 when a PUBLISH Packet is sent to
# a Client because it matches an established subscription regardless
# of how the flag was set in the message it received [MQTT-3.3.1-9].
#
# Since we do not know if a published value is retained we need to
# (re)subscribe, to ensure retained messages are replayed
def _process_client_subscriptions() -> list[tuple[int, int]]:
"""Initiate all subscriptions on the MQTT client and return the results."""
subscribe_result_list = []