0x2142 / frigate-notify

Event notifications for a standalone Frigate NVR instance
https://frigate-notify.0x2142.com/
MIT License
105 stars 9 forks source link

Doesn't seem to stay connected to mosquitto MQTT #136

Closed bobemoe closed 1 month ago

bobemoe commented 1 month ago

Describe the bug Doesn't seem to stay connected to mosquitto MQTT

Expected behavior Stable connection

To Reproduce docker compose up

services:
  frigate:
    container_name: frigate
    privileged: true # this may not be necessary for all setups
    restart: unless-stopped
    image: ghcr.io/blakeblackshear/frigate:stable
    shm_size: "64mb" # update for your cameras based on calculation above
    devices:
      - /dev/apex_0:/dev/apex_0 # Passes a PCIe Coral, follow driver instructions here https://coral.ai/docs/m2/get-started/#2a-on-linux
    volumes:
      - /etc/localtime:/etc/localtime:ro
      - ./frigate/config:/config
      - ./frigate/storage:/media/frigate
      - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    ports:
      - "8971:8971"
      #- "5000:5000" # Internal unauthenticated access. Expose carefully.
      - "8554:8554" # RTSP feeds
      - "8555:8555/tcp" # WebRTC over tcp
      - "8555:8555/udp" # WebRTC over udp
    environment:
      FRIGATE_RTSP_PASSWORD: "password"

  mosquitto:
    image: eclipse-mosquitto:latest
    container_name: mosquitto
    ports:
      - "1883:1883"  # MQTT port
      - "9001:9001"  # WebSocket port (optional)
    volumes:
      - ./mosquitto/config:/mosquitto/config  # Configuration files
      - ./mosquitto/data:/mosquitto/data      # Persistent data
      - ./mosquitto/log:/mosquitto/log        # Log files
    restart: unless-stopped

  frigate-notify:
    image: ghcr.io/0x2142/frigate-notify:latest
    environment:
      - TZ=Etc/UTC
      - FN_DEBUG=true
    volumes:
      - ./frigate-notify/config.yml:/app/config.yml
    restart: unless-stopped

Versions:

Frigate-Notify Config:

frigate:
  server: http://frigate:5000
  public_url: https://xxx

  mqtt: 
    enabled: true 
    server: mosquitto
    port: 1883
    clientid: frigate
    topic_prefix: frigate

alerts:  
  smtp:
    enabled: true
    server: xxx
    port: 25
    recipient: yyy@xxx

Frigate-Notify Logs:

frigate-notify-1  | 2024/09/26 19:31:37 +0000 INF Successfully connected to http://frigate:5000
frigate-notify-1  | 2024/09/26 19:31:37 +0000 INF Config file validated!
frigate-notify-1  | 2024/09/26 19:31:37 +0000 INF App running. Press Ctrl-C to quit.
frigate-notify-1  | 2024/09/26 19:31:37 +0000 INF Connected to MQTT.
frigate-notify-1  | 2024/09/26 19:31:37 +0000 INF Subscribed to MQTT topic: frigate/events
frigate-notify-1  | 2024/09/26 19:31:38 +0000 ERR Lost connection to MQTT broker error=EOF
frigate-notify-1  | 2024/09/26 19:31:38 +0000 INF Connected to MQTT.
frigate-notify-1  | 2024/09/26 19:31:38 +0000 INF Subscribed to MQTT topic: frigate/events
frigate-notify-1  | 2024/09/26 19:31:39 +0000 ERR Lost connection to MQTT broker error=EOF
frigate-notify-1  | 2024/09/26 19:31:40 +0000 INF Connected to MQTT.
frigate-notify-1  | 2024/09/26 19:31:40 +0000 INF Subscribed to MQTT topic: frigate/events
frigate-notify-1  | 2024/09/26 19:31:41 +0000 ERR Lost connection to MQTT broker error=EOF
...repeats forever...

Additional context I know MQTT is working as I'm subscribed in a terminal and can see frigate publishing

0x2142 commented 1 month ago

Hi there, The MQTT clientid needs to be unique. If your Frigate instance is already using the clientid of frigate, then Frigate-Notify should be different. Otherwise they will both conflict & disconnect.

bobemoe commented 1 month ago

Fantastic! Super quick reply thank you very much, that seems to have done it! :D