-
Notifications
You must be signed in to change notification settings - Fork 104
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Resend PUBACK and PUBREC irrespective of the DUP flag #83
Conversation
We already do this, since |
@@ -1054,7 +1054,7 @@ static MQTTStatus_t handleIncomingPublish( MQTTContext_t * pContext, | |||
* state engine. This will be handled by ignoring the | |||
* #MQTTStateCollision status from the state engine. The publish | |||
* data is not passed to the application. */ | |||
else if( ( status == MQTTStateCollision ) && ( publishInfo.dup == true ) ) | |||
else if( status == MQTTStateCollision ) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If we're making this change specifically for AWS IoT Core, we should at least log a warning, if not an error. If the DUP flag isn't set, it seems to be a protocol violation (3.3.1.1):
The DUP flag MUST be set to 1 by the Client or Server when it attempts to re-deliver a PUBLISH Packet
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please see the updated logs.
source/core_mqtt.c
Outdated
|
||
if( publishInfo.dup == false ) | ||
{ | ||
LogError( ( "DUP flag is 0 for duplicate incoming publish packet." ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we have a more ominous sounding error message like "Protocol violation: ..."? I think we should be clear that this isn't according to the spec.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would simply say "DUP flag is 0 for duplicate packet (MQTT-3.3.1.-1)" that gives all the breadcrumbs you need to figure it out. If you just google MQTT-3.3.1.-1 you will hit it directly.
@@ -955,7 +955,7 @@ static MQTTStatus_t deserializeConnack( const MQTTPacketInfo_t * pConnack, | |||
if( ( pRemainingData[ 0 ] & MQTT_PACKET_CONNACK_SESSION_PRESENT_MASK ) | |||
== MQTT_PACKET_CONNACK_SESSION_PRESENT_MASK ) | |||
{ | |||
LogWarn( ( "CONNACK session present bit set." ) ); | |||
LogInfo( ( "CONNACK session present bit set." ) ); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks. I'm pretty sure this was a leftover from v4_beta, where the session present flag wasn't given back to the application
In the OASIS MQTT Version 3.1.1 OASIS Standard, the following is stated:
Also, when AWS IoT Core resends a PUBLISH with the same packet ID as the first that wasn't PUBACK'd, the DUP flag will always be set to 0. Therefore, our library will return
MQTTStateCollision
and will NOT send a PUBACK in response.For QoS 2, the OASIS spec does not seem to explicitly state anything about whether or not to resend a PUBREC in response to a resent PUBLISH with the DUP flag set to 0. However, I think the same logic still applies, so the PUBREC must still be resent in that case. Feel free to disagree.