Healthcheck in Mosquitto docker container
I setup mosquitto password using a password file
volumes:
- /password:/mosquitto/config
How can I add healthcheck in docker-compose? I tried the below solution provided here
https://stackoverflow.com/questions/39275666/script-to-check-mosquitto-is-healthy
but getting error
Connection error: Connection Refused: not authorised
healthcheck:
test: ["CMD-SHELL", "timeout -t 5 mosquitto_sub -t '$$SYS/#' -C 1 | grep -v Error || exit 1"]
interval: 10s
timeout: 10s
retries: 6
Also, I tried a couple of other options but they are asking me to pass username and password. Can't I use this password file?
If you're using a password file for authentication then the client connecting for a health check must use authentication as well.
I did another example here without required password for probes. #1270
Is it probless to expose a http API for health check?
Any resolution to this? The http API would be nice.
Is there any issues with the example I did? https://github.com/eclipse/mosquitto/issues/1270
That’s perfect. Thanks for pointing it out.
From: Tobias Assarsson @.> Date: Monday, June 19, 2023 at 11:08 AM To: eclipse/mosquitto @.> Cc: turboc1208 @.>, Comment @.> Subject: Re: [eclipse/mosquitto] Healthcheck in Mosquitto docker container (Issue #2385)
Is there any issues with the example I did? #1270https://github.com/eclipse/mosquitto/issues/1270
— Reply to this email directly, view it on GitHubhttps://github.com/eclipse/mosquitto/issues/2385#issuecomment-1597441728, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAOQAU4PRLJOWROFIXUYCLDXMB2QNANCNFSM5H7ZEQZQ. You are receiving this because you commented.Message ID: @.***>
If you're using a password file for authentication then the client connecting for a health check must use authentication as well.
Well... not neccessarily. Being rejected by the server's auth also means that it is running 🙂. In many cases that might suffice.