Skip to content

Python MQTT publishers discard enqueue errors and return before QoS acknowledgement #700

Open

Description

@clemensv

The Python mqttclient output used by the frozen USGS WQ feeder ends its async generated publish methods with self.client.publish(target_topic, payload, **publish_kwargs) and discards the returned MQTTMessageInfo. It neither checks rc nor awaits QoS 1 PUBACK. Consequently an awaited generated publish can complete successfully after a local enqueue failure, before acknowledgement, or when the broker rejects PUBACK with a reason >= 128.

Minimal reproducer: inject a Paho-compatible client whose publish returns SimpleNamespace(rc=4) into USGSWaterQualitySitesMqttMqttClient, then await publish_usgs_water_quality_sites_mqtt_monitoring_site(...) with valid generated data. The coroutine returns normally. With rc=0 and no PUBACK, it also returns immediately.

For checkpointed acquisition this can lose observations: committing state after awaited publish still precedes delivery. Please have generated QoS 1/2 publication check enqueue status and expose/await broker completion, including MQTT 5 negative acknowledgement reason codes. Avoid blocking the asyncio loop while awaiting Paho completion.

The feeder currently wraps the unchanged generated publisher with a handwritten Paho boundary: track every MessageInfo, record MQTT 5 on_publish reason codes, and fail flush on missing/rejected acknowledgement. Regression tests exercise actual generated wrappers, successful PUBACK, missing PUBACK and negative PUBACK; state remains unchanged on failure. No generated artifacts were edited.

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions