Skip to content
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

Handler does not work for null body retained messages published before the handler created #127

Closed
freemansgit opened this issue Apr 7, 2021 · 6 comments

Comments

@freemansgit
Copy link

freemansgit commented Apr 7, 2021

Handler does not work for null body retained messages published before the handler created. One service publishes null body messages with retaining True. Another service started later and its handlers don't react only on null-body retained messages. With other kinds of messages, everything is ok and Handlers catch it successfully. Maybe I should add some specific parameters for that case?

@hidaris
Copy link

hidaris commented Apr 8, 2021

It seems that the broker sent the client a retain message before your subscription took effect, did you use the subscription in the on connect callback? I'm wondering if gmqtt can ensure that the subscriptions take effect even when connecting.

@freemansgit
Copy link
Author

freemansgit commented Apr 8, 2021

Yes, we use the subscription in the on_connect callback. We found one interesting info https://community.openhab.org/t/clearing-mqtt-retained-messages/58221 that article says the approach to drop retain message is to send null message to the topic. Our filters wait 'retain' messages and did not react on not 'retain' messages. Maybe this is the answer.

@Lenka42
Copy link
Collaborator

Lenka42 commented Apr 8, 2021

@freemansgit hi, subscription has retain_as_published flag, by default it is False. So by default, when publisher publishes message with retain True and the listener is online, listener will get the message with retain False flag. Listener will receive retain True messages only immediately after subscription, these messages are from broker storage.

@freemansgit
Copy link
Author

This flag did not help, We think that it is mqtt specific point. That retain flag drops if the null message is posted before subscription of the another client

@Lenka42
Copy link
Collaborator

Lenka42 commented Apr 8, 2021

@freemansgit if client subscribes after null retain message is published, it will not get any message from this topic at all. Null message removes retain message in the topic.

@freemansgit
Copy link
Author

Thanks for the quick support. I close the issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants