-
Notifications
You must be signed in to change notification settings - Fork 291
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
Fix: Subscriptions can't be read if arrive when waiting for response of ping or publish #195
Conversation
@rgorosito Hi, thanks for submitting this PR. I agree completely with #2, thank you for adding it, it'll help the In 1),
I'm confused here. The way the library currently works, |
the problem occurs when a new message reaches the subscriber between the ping that was sent and its response received. If you see the log 1:
|
How to reproduce:Problem with ping:
Problem with publish:
|
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.
@rgorosito Ok, this does address a bug I've been having with this library. Requesting clarification + modifications before I merge in....
Also please bump the version number in the library.properties
file so we can release.
When I'm working with the library, I detect that some event was lost. After enabled debug, I've detected 2 situations:
Ping call processPacketsUntil which detect if call new message (appears in debug console), but can't be read in callback or readSubscription.
My fix add a boolean attribute "new_message" (default false) in Adafruit_MQTT_Publish class. It is set to true inside processPacketsUntil. Later, in readSubscription, search if there are pending message. If so, return that message.
Callback don't need to be modified because it call readSubscription.
Sometimes my program fail to publish a message and loss subscription arrived (detected in debug console). The fix was more easy and clean: replase readFullPacket with processPacketsUntil. This permit that a message arrive when waiting for response on QoS>0 and because processPacketsUntil has the expected packet type, the check in the type in buffer is not needed anymore.
Logs
message are parsed, but never read
On publish waiting por ACK, ignore incomming messages and return an error because ACK come later.