Skip to content

Cannot Obtain Packet ID on Publish, Making Concurrent Publishes Difficult #1007

@aa51513

Description

@aa51513

Description
In rumqttc, when calling AsyncClient::publish(), there is no way to retrieve the MQTT packet identifier (packet_id) assigned to the message. This makes it difficult to implement reliable message tracking and retransmission logic for concurrent publishes, since packet_id is only available later through Event::Outgoing(Outgoing::Publish(publish)).

Steps to Reproduce

  1. Create an AsyncClient.

  2. Call client.publish(topic, qos, retain, payload).await.

  3. There is no return value for packet_id.

Expected Behavior
I would expect publish() to either:

  • Return the assigned packet_id immediately, or

  • Provide a mechanism to attach user-defined correlation data that can be reliably retrieved with the packet_id in Outgoing::Publish.

This would allow safely implementing concurrent publishes and retransmission logic without relying on a FIFO matching queue.

Actual Behavior

  • publish() returns ()

  • Packet_id is only visible asynchronously via Event::Outgoing, requiring a pending queue or FIFO matching that blocks true concurrency.

Use Case

  • Providing a Future handle upon publish, allowing retrieval of the packet_id used for this send, which would greatly facilitate message retransmission management.

  • Supporting fully concurrent publishing while maintaining correct mapping between messages and packet_id.

Suggested Solution

  • Either return the assigned packet_id from publish(), or

  • Provide a built-in way to attach a correlation ID to a publish message that is guaranteed to appear with its packet_id in Event::Outgoing.

Environment

rumqttc version: [0.25.0]

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