question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

why republish with new PID?

See original GitHub issue

In the mqtt_as readme you write:

The publication is then attempted again as a new message with a different PID. (The new PID proved necessary for Mosquitto to recognise the message).

Can you describe why a new PID was necessary? If the client reconnects it would be best not to use a new PID to avoid unnecessary duplication of the message if the broker had actually received it. Is there a bug in mosquitto or what did you observe?

Edit: maybe I know what happens: when MQTTClient.publish calls MQTT_base.publish to republish the dup field is set to 0 and mosquitto probably barfs at that if it has indeed seen the packet before. IIUC dup needs to be set to 0 even if republishing on a fresh connection.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:5 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
peterhinchcommented, Mar 10, 2020

Describing this as a bug is overstating the case. A bug would be a program failure or behaviour non-compliant with the MQTT spec. In this instance a deliberate design decision was made which arguably was not optimal. I don’t believe it’s non-compliant, but if you can point me to a specific para in the spec I will reconsider.

Duplicate messages are a declared hazard of qos==1.

If these are problematic, an application subscribing at qos==1 to a qos==1 publication will implement de-duping, if only because the broker can legally send them. Application-level de-duping will use an application-level message ID and won’t care about the PID.

The worst consequence of this behaviour is a small increase in network traffic and subscriber work, and then only in the uncommon instance of an outage experienced by the publisher.

I will review this in due course in conjunction with the MQTT spec, but I don’t regard it as a priority.

0reactions
peterhinchcommented, Mar 17, 2020

The publisher embeds a unique message ID in the message. Each subscriber keeps a log of received ID’s and discard messages whose ID is in that log. If either the MQTT library or the broker cause a duplicate message to be published, it will be discarded.

The application need not know or care about PID’s: a PID is just a unique message ID. Producing one at application level is trivial.

Under the constraints of qos==1 the broker may send a duplicate to subscribers. Unless qos==2 can be used the application must solve the problem of non-idempotent messages whatever MQTT module is in use. I therefore don’t see this as a meaningful issue with this module.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why Publishers Should Care About Persistent Identifiers
PIDs are here to stay because they offer policy-makers a transparent mechanism for tracking the impact of the strategic decisions they make, but ......
Read more >
Introduction to Persistent Identifiers
PID is a new name for a concept that has been a part of publishing for decades. In the past publishers used identifiers...
Read more >
PIDs for Publishers - The PID Forum
This solidifies the scientific record and publication process, and allows scholarly assets to be easily found, referenced, and claimed.
Read more >
Connected Research: The Potential of the PID Graph - PMC
The PID Graph establishes connections between different entities within the research landscape, thereby enabling both researchers and ...
Read more >
Connected Research: The Potential of the PID Graph
The foundational PID infrastructure mentioned above provides a layer upon which to build new PIDs for new entities that people want to be...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found