1

I have an OpenHAB container and a Mosquitto container; what is the best way to restart the OpenHAB if Mosquitto is updated? Upon restarting or updating the Mosquitto, the OpenHAB (and home assistant) do not reconnect to the MQTT

Ebi
  • 373
  • 2
  • 12
  • Why do you think you need to restart the openhab container? Any MQTT clients should just reconnect when the broker restarts, show long have you left it? – hardillb Oct 17 '22 at 07:18
  • And have you raised issues with the OpenHAB/HA projects about the fact they don't reconnect? – hardillb Oct 17 '22 at 10:35
  • the problem happends when i update de mqtt brocker docker, all the HA/OH was disconnect, when i restart both everything was back online – Fernando Benavides Oct 20 '22 at 03:03

1 Answers1

1

It is better to set a healthcheck for your failing containers. So, in the case that the mosquitto server is updated and they fail to connect, they can restart. For example:

version: '3.4'
services:
  web:
    image: very-simple-web
    build:
      context: ./
      dockerfile: Dockerfile
    restart: unless-stopped
    ports:
      - "80:80"
    healthcheck:
      test: curl --fail http://localhost || exit 1
      interval: 60s
      retries: 5
      start_period: 20s
      timeout: 10s

In this case very-simple-web, will fail if a request to http://localhost and restart until the healtcheck succeeds. So, you should add healthchecks for openhab and home assistant

paltaa
  • 2,985
  • 13
  • 28
  • the problem is that they dont fail, they keep running but the openhab and home assistant dont connect to the mqtt – Fernando Benavides Oct 17 '22 at 03:57
  • So you want them to fail in the case that they are not connected to the mqtt. So they will restart and reconnect to the mqtt – paltaa Oct 17 '22 at 13:45