mosquitto icon indicating copy to clipboard operation
mosquitto copied to clipboard

Healthcheck in Mosquitto docker container

Open genieai-vikas opened this issue 4 years ago • 7 comments

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?

genieai-vikas avatar Nov 14 '21 12:11 genieai-vikas

If you're using a password file for authentication then the client connecting for a health check must use authentication as well.

ralight avatar Nov 15 '21 22:11 ralight

I did another example here without required password for probes. #1270

Daedaluz avatar Nov 16 '21 09:11 Daedaluz

Is it probless to expose a http API for health check?

liangyuanpeng avatar Dec 17 '21 08:12 liangyuanpeng

Any resolution to this? The http API would be nice.

turboc1208 avatar Jun 19 '23 15:06 turboc1208

Is there any issues with the example I did? https://github.com/eclipse/mosquitto/issues/1270

Daedaluz avatar Jun 19 '23 16:06 Daedaluz

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: @.***>

turboc1208 avatar Jun 19 '23 17:06 turboc1208

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.

lukasradek avatar Sep 23 '25 14:09 lukasradek