4nte / mqtt-mirror

Fork MQTT traffic from broker A to B like it's potatoes 🥔.
MIT License
40 stars 4 forks source link

After 3 days the mirror breaks down. So here is a helper for anyone encountering the same issue., #6

Open cocoonkid opened 4 months ago

cocoonkid commented 4 months ago

After 3 days the mirror breaks down. So here is a helper for anyone encountering the same issue.

I haven't got time to research the underlying issue, but this way it happily mirrors away for me, for 36days and counting.

This basically restarts the mirror container once every 24hrs.

services:
  mqtt_mirror:
    container_name: mqtt-mirror
    restart: unless-stopped
    image: antegulin/mqtt-mirror
    command: ./mqtt-mirror --source tcp://host.docker.internal:1883  --target tcp:/<target>:1883
    extra_hosts:
      - "host.docker.internal:host-gateway"

  restarter:
    container_name: restarter
    image: docker:cli
    volumes: ["/var/run/docker.sock:/var/run/docker.sock"]
    command: /bin/sh -c "while true; do sleep 86400; docker restart mqtt-mirror && echo \"mqtt-mirror restarted at \$(date)\"; done"
    ports: []
    restart: unless-stopped