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

messages are no longer retained with 2.0.16+ (with a lot of reained topics?) #2887

Open
BubuOT opened this issue Aug 31, 2023 · 43 comments
Open

Comments

@BubuOT
Copy link

BubuOT commented Aug 31, 2023

Since upgrading to mosquitto 2.0.16 (and later 2.0.17) (via docker image) retained messages received by the broker are no longer handled as retained and not delivered to new subscribers.

Downgrading to 2.0.15 makes this work as expected again.

(Happy to add more details about our setup if required)

@BubuOT
Copy link
Author

BubuOT commented Sep 1, 2023

I tried to repliciate the problem in a test setup including another mosquitto as an mqtt brigde but so far was unable to replicate the problem. Will keep you updated.

@stigvi
Copy link

stigvi commented Sep 5, 2023

Downgrading to 2.0.15 makes this work as expected again.

Yes, I did the same after a lot of troubles with no retained messages with 2.0.17

@BubuOT
Copy link
Author

BubuOT commented Sep 5, 2023

@stigvi Good to know we are at least not alone with this problem. Did you find a way to reproduce this problem somehow?

@pat1
Copy link

pat1 commented Sep 11, 2023

duplicated of #2806 and #2618

@pat1
Copy link

pat1 commented Sep 11, 2023

related to #2785

@BubuOT
Copy link
Author

BubuOT commented Sep 11, 2023

@pat1

duplicated of #2806 and #2618

I'm not sure it is? We do not experience this problem here with 2.0.15, which is explicitly mentioned in the other issue(s) as affected.

@ralight
Copy link
Contributor

ralight commented Sep 12, 2023

@BubuOT I've been unable to reproduce this so far. Are you able to share any more details about the setup and what sorts of topics you are using?

@clintkev251
Copy link

I've also seen this. Specifically I'm using mosquitto with Home Assistant and Zigbee2MQTT in this case. Previously, when Home Assistant was restarted, it would read device configurations set as retained messages from Zigbee2MQTT automatically. However on 2.0.17, it would seemingly never be able to receive these retained messages and as a result devices remained unavailable until a restart of Zigbee2MQTT to force it to republish all of the discovery topics at which point they would be successfully received by Home Assistant

I confirmed that rolling back to 2.0.15, this began working as expected again. Let me know if there's any other information that would be helpful in reproducing

@BubuOT
Copy link
Author

BubuOT commented Sep 18, 2023

@ralight I have so far also been unable to reproduce this outside our production environment :-/

Here's our mosquitto config though:

# A full description of the configuration file is at
# /usr/share/doc/mosquitto/examples/mosquitto.conf.example

# >> AUTHENTICATION

# clients must authenticate
#allow_anonymous false
#password_file /mosquitto/config/passwd

# access control list
acl_file /mosquitto/config/acl

# >> PERSISTANCE

# save in-memory database for persistance to disk
autosave_interval 60

# write persistance data to the disk instead of storing only in memory
persistence true
persistence_location /mosquitto/data/

# >> LOGGING

# include timestamp
log_timestamp true

# Possible types are: debug, error, warning, notice, information, subscribe, unsubscribe, websockets, none, all.
#log_type all
#log_type debug
log_type error
log_type warning
#log_type notice
#log_type information
#log_type subscribe
#log_type unsubscribe

# If set to true, the log will include entries when clients connect and disconnect.
connection_messages true

# >> LISTENER

# plain mqtt protocol
# bind to 1883 public since security access is handled
# through docker container isolation
listener 1883
require_certificate true
use_identity_as_username true
use_username_as_clientid true
certfile /mosquitto/config/mqtt.othermo.de.crt
cafile /mosquitto/config/ca.crt
keyfile /mosquitto/config/mqtt.othermo.de.key
# use CRL to prevent revoked clients to access
crlfile /mosquitto/config/crl.pem

# encrypted listener on 8883
listener 8883
require_certificate true
use_identity_as_username true
use_username_as_clientid true
certfile /mosquitto/config/mqtt.othermo.de.crt
cafile /mosquitto/config/ca.crt
keyfile /mosquitto/config/mqtt.othermo.de.key
# use CRL to prevent revoked clients to access
crlfile /mosquitto/config/crl.pem

The bridge config (not sure if relevant.) looks like this:

connection_messages false
connection upstream
address <DOMAIN>

bridge_protocol_version mqttv311
bridge_insecure false
bridge_cafile <filename>
bridge_certfile <filename>
bridge_keyfile<filename>

notifications true

notification_topic {DEVICEID}/status
<list of bridged topics; mix between in an out and qos 0 and 1>
remote_clientid {DEVICEID}

@ralight
Copy link
Contributor

ralight commented Sep 18, 2023

Ok, thank you. I will keep looking, and if you find a way to reproduce it please let me know.

@simonclayton
Copy link

simonclayton commented Sep 26, 2023

We have this exact issue when upgrading mosquitto 2.0.15 to 2.0.18 on docker. I can replicate the issue with data "missing" on 2.0.16, 2.0.17 and 2.0.18 but switching back to the 2.0.15 docker image just by editing the docker-compose.yml file and restarting immediately "fixes" everything without needing to republish any data.

In case it helps, we only start to see the issue with increasing volumes of data. We have 2 top level topics with a number of nested topics and at ~30k topics published on 2.0.15 or 2.0.18, connecting with MQTT Explorer shows ~1400 topics as the complete data set.

Testing with only one top level topic with ~1100 subtopics, we get all of the data sent to the client correctly. It is only when we add a 2nd top level topic with ~28k subtopics that we start to see issues.

For reference - our topic structure looks like this

--- topic1 (~1100 subtopics in total)
 |       |- sub1
 |       |     |- sub-subtopics1..10
 |       |     |                |- data topics
 |       | 
 |       |- sub2
 |       |     |- sub-subtopics1..2
 |       |     |                |- data topics
 |       | 
 |- topic2 (~28k subtopics in total)
 |       |- sub1
 |       |     |- sub-subtopics1..10
 |       |     |                |- data topics
 |       | 
 |       |- sub2
 |       |     |- sub-subtopics1..2
 |       |     |                |- data topics

I have a test server that only has dockerized mosquitto on and no personal data that I can let a project dev have root access to if you want to see this happening.

@BubuOT
Copy link
Author

BubuOT commented Oct 5, 2023

FWIW, we also have a lot of retained topics (~10k) in production where we saw this issue. This might explain why I've never been able to reproduce this in any test setup 🤔.

@ZetaWaves
Copy link

I am having the same issue. All devices come up as "Unavailable" on Home Assistant after an HA reboot.
Is this being worked on? This is a critical bug as my entire network is down with no fix.

@clintkev251
Copy link

Well you can temporarily fix it very easily by reverting to 2.0.15 where retained topics are working as expected

@ZetaWaves
Copy link

Well you can temporarily fix it very easily by reverting to 2.0.15 where retained topics are working as expected

Not possible. I’m using MQTT HA Addon. No way to go back in version unfortunately.

@Soukyuu
Copy link

Soukyuu commented Oct 9, 2023

I just restored to HA addon version 6.2.1, which still has mosquito 2.0.15 - backups are a life saver.

@ZetaWaves
Copy link

I just restored to HA addon version 6.2.1, which still has mosquito 2.0.15 - backups are a life saver.

I'm happy for you, but unfortunately, I wasn't aware of when the problem started until I had to reboot HA.
So all my backups are useless because I've made changes since then and I can't go back especially since I'm not sure when I upgraded the MQTT broker add-on. So yeah - this completely breaks using any MQTT device for me. Network has been down for some time. I will likely drop MQTT at this point because the dev's don't seem to be making this a priority fix.

@Soukyuu
Copy link

Soukyuu commented Oct 10, 2023

@ZetaWaves: HA does partial backups before every update by default, are you sure you have none? Or have you disabled that?

@WhimsySpoon
Copy link

I have the same issue with HA Core 2023.10.1, the HA Add-on v6.3.1 (2.0.17) and Zigbee2MQTT. Several devices became Unknown, even though they had a state in Z2M.

Restoring my add-on back to the version with 2.0.15 has resolved the issue. I have ~1400 topics.

@wardwolfram
Copy link

I just restored to HA addon version 6.2.1, which still has mosquito 2.0.15 - backups are a life saver.

I issues a partial restore to MQTT broker 6.2.1. After the restore, I received the following message:
image

How did you restore to 6.2.1 successfully? Thanks much in advance.

@tomlut
Copy link

tomlut commented Oct 14, 2023

That's something you should ask Home Assistant, not Mosqitto.

@wardwolfram
Copy link

That's something you should ask Home Assistant, not Mosqitto.

Yes, restoring Mosqitto from HA.

@wardwolfram
Copy link

I just restored to HA addon version 6.2.1, which still has mosquito 2.0.15 - backups are a life saver.

I issues a partial restore to MQTT broker 6.2.1. After the restore, I received the following message: image

How did you restore to 6.2.1 successfully? Thanks much in advance.

Solved.

  1. Stopped the Zigbee2MQTT add-on service
  2. Stopped the Mosquitto Broker add-on service
  3. Uninstalled the Mosquitto Broker add-on
  4. HA partial restore of the Mosquitto Broker add-on v6.2.1
  5. Started the 2 services up successfully.

I agree with Soukyuu... backups are indeed a life saver!

@Alphaemef
Copy link

anyone know if this has been fixed in the recent updates or if a fix is coming ? I am still sitting on 2.0.16 for the same reason.

@tomlut
Copy link

tomlut commented Nov 28, 2023

Yes there is a bugfix for this included. See:

https://mosquitto.org/blog/2023/09/version-2-0-18-released/

@Alphaemef
Copy link

Aha so this was actually #2893 Perfect, thanks!

@Alphaemef
Copy link

Alphaemef commented Nov 28, 2023

sigh nope... when I log on with MQTT explorer, none of the messages are retained. Back to 2.0.15 :/

@ZetaWaves
Copy link

It is not fixed in 2.0.18.

Still broken. Just tested.

@ZetaWaves
Copy link

Yes there is a bugfix for this included. See:

https://mosquitto.org/blog/2023/09/version-2-0-18-released/

It is not fixed in this release. Actually - it's worse in this release than before.

@tomlut
Copy link

tomlut commented Nov 28, 2023

Working for me.

@Alphaemef
Copy link

It may be an issue with the MQTT broker addon for HA. I have around 30 clients, each with around 100 entities. And not a single message is retained, despite several reboots etc. Retained messages however work with version 2.0.15 (Addon version 6.21).

Anyone know who maintains the addon ?

@tomlut
Copy link

tomlut commented Nov 28, 2023

Frenk. You can have a chat on discord here: https://discord.gg/jBwTDzJ4sk

I'm using the HA addon but don't have anywhere near that many topics.

@Alphaemef
Copy link

From what I can gather, its primarily hitting users with a lot of topics (I guess 5550 topics is high). Its so rarely reported though, I don't even know where to look. Will check out the discord.

@euggersh
Copy link

If you find out anything interesting on Discord, a post here would be very much appreciated.

@Alphaemef
Copy link

Tagged French. Will see if he has ny comments or guidance. Might just be time to host the MQTT broker outside HA, which I really was hoping to avoid.

@clintkev251
Copy link

I don't think it's anything specific to hosting the broker in HA, it's the same container regardless of where you're hosting it. I run mine completely independently and I'm still impacted by this

@BubuOT
Copy link
Author

BubuOT commented Nov 28, 2023

2.0.18 doesn't fix this, no.

E: Updated the title to reflect this. Also added a hint that this might be related to having a lot of retained topics.

@BubuOT BubuOT changed the title messages are no longer retained with 2.0.16 (or 2.0.17) messages are no longer retained with 2.0.16+ Nov 28, 2023
@BubuOT BubuOT changed the title messages are no longer retained with 2.0.16+ messages are no longer retained with 2.0.16+ (with a lot of reained topics?) Nov 28, 2023
@scottshanafelt
Copy link

Just adding that I ran into this problem running 2.0.18 and downgrading to 2.0.15 resolved the issue. Basically the broker just won't retain messages. I even manually try to set a retained message using MQTTExplorer and even that fails to retain. All good on 2.0.15

@Alphaemef
Copy link

Just adding that I ran into this problem running 2.0.18 and downgrading to 2.0.15 resolved the issue. Basically the broker just won't retain messages. I even manually try to set a retained message using MQTTExplorer and even that fails to retain. All good on 2.0.15

Yeah its likely the same issue. I totally get that this isn't necessarily fixed immediately. But it sure would be nice if it at least could get acknowledged as an actual issue.

@digiblur
Copy link

I can also confirm this issue. Rolled back my container tag to 2.0.15 and all is well again with Zigbee2MQTT and HA.

@MnM001
Copy link

MnM001 commented Apr 6, 2024

Not worried about this in version 2.0.15?

image

@stigvi
Copy link

stigvi commented Apr 6, 2024

Not worried about this in version 2.0.15?

Why do you ask? What alternatives are there?

@MnM001
Copy link

MnM001 commented Apr 6, 2024

No idea... new 2.0.15 image with vulnerabilities fixed?

I mean if you thought that it was bad when devices were not working, I really think it will be way worst than that if someone manages to exploit these vulnerabilities.
And as the mqtt owner is aware that any versions after 2.0.15 have issues maybe they might have a duty of care to build a new 2.0.15 version without vulnerabilities?

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