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

Keep messages on bridge configuration reload #2567

Open
phlundblom opened this issue Jun 14, 2022 · 3 comments
Open

Keep messages on bridge configuration reload #2567

phlundblom opened this issue Jun 14, 2022 · 3 comments

Comments

@phlundblom
Copy link

phlundblom commented Jun 14, 2022

I thought I finally had a way to use Mosquitto as a bridge between local client and Google Cloud Platform IoT Core, thanks to some helpful hints here. Unfortunately I have run into a problem, again.

Setup

  • Latest Mosquitto develop running on Debian Bullseye
  • Connecting to GCP IoT Core MQTT bridge
  • Messages to save locally have QoS set to 1
  • Configuration as follows
listener 1883
allow_anonymous true
autosave_interval 600

connection iotcore
address mqtt.googleapis.com:8883
topic /devices/mydevice/events/# out 1
topic /devices/mydevice/commands/# in 0
topic /devices/mydevice/config in 1
topic /devices/mydevice/state/# out 0

remote_clientid projects/myproject/locations/europe-west1/registries/myregistry/devices/mydevice

remote_password <valid_jwt>

remote_username unused

try_private false
bridge_cafile /somecerts.pem
bridge_attempt_unsubscribe false
bridge_protocol_version mqttv311
cleansession false
keepalive_interval 120
notifications false

bridge_reload_type immediate

What I want to achieve

During a network outage, I want Mosquitto to cache all messages and when connection to IoT Core MQTT bridge is re-established, the messages should be sent.

What I see

Unfortunately the IoT Core MQTT bridge requires the client to re-authenticate with an updated JWT (set as password) periodically. As of now, I do this by updating the remote_password property in the Mosquitto configuration fil and then send a SIGHUP to the process. This is all and well when the network is up and no local messages are cached by Mosquitto. If instead, the connection to IoT Core is down and local messages are cached, it seems they all will be thrown away as soon as Mosquitto identifies a configuration change for the bridge.

I can see the point of flushing saved messages for a bridge if there is a configuration change. Unfortunately it results in dropped messages in my use case. I also tried to use bridge_reload_type lazy but the end result is the same, probably because of the changed password.

Question

Is there a way to change the remote_password for a bridge without Mosquitto flushing all cached messages for the bridge upon re-connection after the password change?

@ralight
Copy link
Contributor

ralight commented Aug 15, 2022

Thanks for the report, I'm looking into this and know what the problem is - I'm not sure the best way to fix it at the moment though.

@jitbasemartin
Copy link

Hi @phlundblom ! I have the same issue, do you found a better workaround ? Thanks

@phlundblom
Copy link
Author

Hi @phlundblom ! I have the same issue, do you found a better workaround ? Thanks

Unfortunately not. I assume it's not that hard to fix and submit a PR but haven't come to it because we are currently redesigning our setup and I'm not sure what role Mosquitto will have in the new one.

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