blakeblackshear / frigate

NVR with realtime local object detection for IP cameras
https://frigate.video
MIT License
19.2k stars 1.76k forks source link

[Support]: frigate.comms.mqtt: Unable to publish to stats: client is not connected #8083

Closed sgzmd closed 1 year ago

sgzmd commented 1 year ago

Describe the problem you are having

I am running Frigate in Docker Compose, alongside Mosquitto and go2rpc. Frigate refuses to connect to the MQTT with the following error message in logs:

2023-10-06 16:18:46.708048635  [2023-10-06 16:18:46] frigate.comms.mqtt             ERROR   : Unable to publish to Outdoor/all: client is not connected
2023-10-06 16:19:27.333091671  [2023-10-06 16:19:27] frigate.comms.mqtt             ERROR   : Unable to publish to Outdoor/motion: client is not connected
2023-10-06 16:19:58.057959711  [2023-10-06 16:19:58] frigate.comms.mqtt             ERROR   : Unable to publish to stats: client is not connected

I have verified that I can indeed connect from Frigate container to Mosquitto and publish messages there like this:

root@bi2:/opt/frigate# mosquitto_pub -h myhostname  -p 1883 -t Hello -m World

I tried replacing myhostname in Frigate config to IP address of the host, IP address of the container as well as 127.0.0.1. I have also tried to run another MQTT server not in docker (neither require authentication and both allow anonymous posters). At this point I'm at my wit's end as per what to do.

Version

0.12.1-367D724

Frigate config file

mqtt:
  host: myhostname
  port: 1883
logger:
  default: info
  logs:
    frigate.mqtt: debug
cameras:
  Outdoor:
    ffmpeg:
      hwaccel_args: preset-vaapi
      inputs:
        - path: rtsp://myhostname:18554/Outdoor
          input_args: preset-rtsp-restream
          roles:
            - detect
            - record
    record:
      enabled: True
      events:
        retain:
          default: 100
          mode: motion
    detect:
      enabled: True
      width: 640
      height: 480
      fps: 10

detectors:
  coral:
    type: edgetpu
    device: usb  

ffmpeg:
  hwaccel_args:
    - -hwaccel
    - vaapi
    - -hwaccel_device
    - /dev/dri/renderD128
    - -hwaccel_output_format
    - yuv420p

Relevant log output

2023-10-06 16:18:46.708048635  [2023-10-06 16:18:46] frigate.comms.mqtt             ERROR   : Unable to publish to Outdoor/all: client is not connected
2023-10-06 16:19:27.333091671  [2023-10-06 16:19:27] frigate.comms.mqtt             ERROR   : Unable to publish to Outdoor/motion: client is not connected
2023-10-06 16:19:58.057959711  [2023-10-06 16:19:58] frigate.comms.mqtt             ERROR   : Unable to publish to stats: client is not connected

FFprobe output from your camera

N/A

Frigate stats

{"Outdoor":{"camera_fps":10.0,"capture_pid":306,"detection_enabled":1,"detection_fps":0.0,"ffmpeg_pid":310,"pid":304,"process_fps":10.0,"skipped_fps":0.0},"cpu_usages":{"%Cpu(s):":{"cpu":"id,","mem":"0.2"},"1":{"cpu":"0.0","mem":"0.0"},"109":{"cpu":"0.0","mem":"0.0"},"112":{"cpu":"1.3","mem":"3.1"},"116":{"cpu":"0.0","mem":"0.2"},"134":{"cpu":"0.0","mem":"0.1"},"135":{"cpu":"0.0","mem":"0.1"},"136":{"cpu":"0.0","mem":"0.1"},"137":{"cpu":"0.0","mem":"0.1"},"15":{"cpu":"0.0","mem":"0.0"},"16":{"cpu":"0.0","mem":"0.0"},"24":{"cpu":"0.0","mem":"0.0"},"25":{"cpu":"0.0","mem":"0.0"},"26":{"cpu":"0.0","mem":"0.0"},"27":{"cpu":"0.0","mem":"0.0"},"28":{"cpu":"0.0","mem":"0.0"},"281":{"cpu":"0.0","mem":"1.0"},"29":{"cpu":"0.0","mem":"0.0"},"295":{"cpu":"0.3","mem":"0.1"},"296":{"cpu":"0.0","mem":"1.3"},"298":{"cpu":"1.3","mem":"1.1"},"30":{"cpu":"0.0","mem":"0.0"},"304":{"cpu":"2.3","mem":"1.2"},"305":{"cpu":"0.0","mem":"0.2"},"306":{"cpu":"3.0","mem":"1.1"},"31":{"cpu":"0.0","mem":"0.0"},"310":{"cpu":"8.0","mem":"0.9"},"312":{"cpu":"0.0","mem":"0.2"},"32":{"cpu":"0.0","mem":"0.0"},"41":{"cpu":"0.0","mem":"0.0"},"42":{"cpu":"0.3","mem":"0.0"},"4861":{"cpu":"0.0","mem":"0.0"},"4934":{"cpu":"0.0","mem":"0.0"},"80":{"cpu":"0.0","mem":"0.0"},"81":{"cpu":"0.0","mem":"0.0"},"82":{"cpu":"0.0","mem":"0.0"},"847":{"cpu":"0.0","mem":"0.0"},"MiB":{"cpu":"5589.9","mem":"avail"},"PID":{"cpu":"%CPU","mem":"%MEM"},"Tasks:":{"cpu":"stopped,","mem":"0"},"top":{"cpu":"users,","mem":"load"}},"detection_fps":0.0,"detectors":{"coral":{"detection_start":0.0,"inference_speed":11.74,"pid":296}},"gpu_usages":{"intel-vaapi":{"gpu":"5.84 %","mem":"- %"}},"service":{"last_updated":1696606083,"latest_version":"0.12.1","storage":{"/dev/shm":{"free":65.8,"mount_type":"tmpfs","total":67.1,"used":1.3},"/media/frigate/clips":{"free":1958742.8,"mount_type":"fuseblk","total":8001545.0,"used":6042802.3},"/media/frigate/recordings":{"free":1958742.8,"mount_type":"fuseblk","total":8001545.0,"used":6042802.3},"/tmp/cache":{"free":995.5,"mount_type":"tmpfs","total":1000.0,"used":4.5}},"temperatures":{},"uptime":559,"version":"0.12.1-367d724"}}

Operating system

Debian

Install method

Docker Compose

Coral version

USB

Network connection

Wired

Camera make and model

Reolink

Any other information that may be helpful

Recreating Docker container doesn't help

NickM-27 commented 1 year ago

Need to see full logs, 127.0.0.1 definitely won't work since that's restricted to the container, no idea why the IP address wouldn't work but would also want to see mqtt logs

sgzmd commented 1 year ago

More logs here:

2023-10-06 16:18:42.262922769  [INFO] Starting Frigate...
2023-10-06 16:18:43.788129086  [2023-10-06 16:18:43] frigate.app                    INFO    : Starting Frigate (0.12.1-367d724)
2023-10-06 16:18:43.812467774  [2023-10-06 16:18:43] peewee_migrate                 INFO    : Starting migrations
2023-10-06 16:18:43.996835350  [2023-10-06 16:18:43] peewee_migrate                 INFO    : There is nothing to migrate
2023-10-06 16:18:44.032565657  [2023-10-06 16:18:44] detector.coral                 INFO    : Starting detection process: 296
2023-10-06 16:18:46.679062678  [2023-10-06 16:18:44] frigate.app                    INFO    : Output process started: 298
2023-10-06 16:18:46.683812723  [2023-10-06 16:18:44] frigate.detectors.plugins.edgetpu_tfl INFO    : Attempting to load TPU as usb
2023-10-06 16:18:46.684025889  [2023-10-06 16:18:44] frigate.app                    INFO    : Camera processor started for Outdoor: 304
2023-10-06 16:18:46.684143257  [2023-10-06 16:18:46] frigate.detectors.plugins.edgetpu_tfl INFO    : TPU found
2023-10-06 16:18:46.684292912  [2023-10-06 16:18:44] frigate.app                    INFO    : Capture process started for Outdoor: 306
2023-10-06 16:18:46.708048635  [2023-10-06 16:18:46] frigate.comms.mqtt             ERROR   : Unable to publish to Outdoor/all: client is not connected
2023-10-06 16:19:27.333091671  [2023-10-06 16:19:27] frigate.comms.mqtt             ERROR   : Unable to publish to Outdoor/motion: client is not connected
2023-10-06 16:19:58.057959711  [2023-10-06 16:19:58] frigate.comms.mqtt             ERROR   : Unable to publish to stats: client is not connected
2023-10-06 16:20:01.056566218  [2023-10-06 16:20:01] frigate.comms.mqtt             ERROR   : Unable to publish to Outdoor/motion: client is not connected
2023-10-06 16:20:20.517190401  [2023-10-06 16:20:20] frigate.comms.mqtt             ERROR   : Unable to publish to Outdoor/motion: client is not connected
2023-10-06 16:20:21.888440870  [2023-10-06 16:20:21] frigate.comms.mqtt             ERROR   : Unable to publish to events: client is not connected
2023-10-06 16:20:21.908465864  [2023-10-06 16:20:21] frigate.comms.mqtt             ERROR   : Unable to publish to Outdoor/person/snapshot: client is not connected
2023-10-06 16:20:21.908640316  [2023-10-06 16:20:21] frigate.comms.mqtt             ERROR   : Unable to publish to Outdoor/person: client is not connected
2023-10-06 16:20:21.908760125  [2023-10-06 16:20:21] frigate.comms.mqtt             ERROR   : Unable to publish to Outdoor/all: client is not connected

There's nothing whatsoever in MQTT logs - it is very clear that Frigate is not even reaching it.

sgzmd commented 1 year ago

So through some hacking of Docker I got it to the point that Frigate now is connecting to Mosquitto. In the logs I see:

frigate           | 2023-10-07 14:32:20.136140332  [2023-10-07 14:32:20] frigate.comms.mqtt             ERROR   : Unable to publish to Outdoor/person/snapshot: client is not connected
mqtt              | 1696685547: New connection from 172.26.0.3:48473 on port 1883.
mqtt              | 1696685547: Client <unknown> disconnected due to protocol error.
frigate           | 2023-10-07 14:32:38.221267741  [2023-10-07 14:32:38] frigate.comms.mqtt             ERROR   : Unable to publish to stats: client is not connected
NickM-27 commented 1 year ago

something still seems weird with having that protocol error

sgzmd commented 1 year ago

Indeed. So far I've tried to configure password on Mosquitto, and make Frigate use it, which didn't have any desired effect. I can connect to Mosquitto using this username/password using other clients.

Roman @.*** https://twitter.com/sgzmd" Kirillov

------ Original Message ------ From "Nicolas Mowen" @.> To "blakeblackshear/frigate" @.> Cc "sgzmd" @.>; "Author" @.> Date 07/10/2023 14:34:47 Subject Re: [blakeblackshear/frigate] [Support]: frigate.comms.mqtt: Unable to publish to stats: client is not connected (Issue #8083)

something still seems weird with having that protocol error

— Reply to this email directly, view it on GitHub https://github.com/blakeblackshear/frigate/issues/8083#issuecomment-1751714692, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAWQAPPUR56FGVFRF7KJ4LX6FK7PAVCNFSM6AAAAAA5V7YNPKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJRG4YTINRZGI. You are receiving this because you authored the thread.Message ID: @.***>

NickM-27 commented 1 year ago

may be something weird with the network still, mosquitto is very common to use with frigate and I also use it myself

sgzmd commented 1 year ago

I have no doubts about it. Is there some way I can increase the verbosity of logging in Frigate so it starts spewing out all of the errors and exceptions as-is? I have

logger:
   default: info
   logs:
     frigate.mqtt: debug

this set up.

Roman @.*** https://twitter.com/sgzmd" Kirillov

------ Original Message ------ From "Nicolas Mowen" @.> To "blakeblackshear/frigate" @.> Cc "sgzmd" @.>; "Author" @.> Date 07/10/2023 14:44:10 Subject Re: [blakeblackshear/frigate] [Support]: frigate.comms.mqtt: Unable to publish to stats: client is not connected (Issue #8083)

may be something weird with the network still, mosquitto is very common to use with frigate and I also use it myself

— Reply to this email directly, view it on GitHub https://github.com/blakeblackshear/frigate/issues/8083#issuecomment-1751716684, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAAWQAPLEE4QFGNLPSEMBXLX6FMCVAVCNFSM6AAAAAA5V7YNPKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTONJRG4YTMNRYGQ. You are receiving this because you authored the thread.Message ID: @.***>

NickM-27 commented 1 year ago

it would be frigate.comms.mqtt: debug

sgzmd commented 1 year ago

So I enabled debugging globally. What is really curious, I am not seeing any debug messages from this branch of code:

    def _on_connect(
        self,
        client: mqtt.Client,
        userdata: Any,
        flags: Any,
        rc: mqtt.ReasonCodes,
    ) -> None:
        """Mqtt connection callback."""
        threading.current_thread().name = "mqtt"
        if rc != 0:
            if rc == 3:
                logger.error(
                    "Unable to connect to MQTT server: MQTT Server unavailable"
                )
            elif rc == 4:
                logger.error(
                    "Unable to connect to MQTT server: MQTT Bad username or password"
                )
            elif rc == 5:
                logger.error("Unable to connect to MQTT server: MQTT Not authorized")
            else:
                logger.error(
                    "Unable to connect to MQTT server: Connection refused. Error code: "
                    + str(rc)
                )

        self.connected = True
        logger.debug("MQTT connected")
        client.subscribe(f"{self.mqtt_config.topic_prefix}/#")
        self._set_initial_topics()

As if it is never called

NickM-27 commented 1 year ago

right, meaning it is never connecting to mosquitto (which makes sense because generally there are no logs in mosquitto)

sgzmd commented 1 year ago

I got it.

        if self.mqtt_config.tls_ca_certs is not None:
            if (
                self.mqtt_config.tls_client_cert is not None
                and self.mqtt_config.tls_client_key is not None
            ):
                self.client.tls_set(
                    self.mqtt_config.tls_ca_certs,
                    self.mqtt_config.tls_client_cert,
                    self.mqtt_config.tls_client_key,
                )
            else:
                self.client.tls_set(self.mqtt_config.tls_ca_certs)

I had tls certs specified in the config, although they weren't used. When I commented that line, things started magically working. What is curious are two things:

  1. Setting TLS on connection that doesn't require it in theory shouldn't break things
  2. Even if it should, at the very least there should be some sensible output in the logs.
github-actions[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

KickingAss2024 commented 8 months ago

how did you fix this as I getting the same?

stokedout commented 8 months ago

I've experienced and fixed this for those using Mosquito via docker compose. Initially I seen this partial log upon running docker compose up

x@x:~/frigate$ docker compose up
[+] Running 4/3
 ✔ Network frigate_default                                              Created                                                                                                                        0.1s 
 ✔ Container frigate                                                    Created                                                                                                                        0.2s 
 ✔ Container mosquitto                                                  Created                                                                                                                        0.2s 
 ! mosquitto Published ports are discarded when using host network mode                                                                                                                                0.0s 
Attaching to frigate, mosquitto
mosquitto  | 1710016651: mosquitto version 2.0.18 starting
mosquitto  | 1710016651: Config loaded from /mosquitto/config/mosquitto.conf.
mosquitto  | 1710016651: Starting in local only mode. Connections will only be possible from clients running on this machine.
mosquitto  | 1710016651: Create a configuration file which defines a listener to allow remote access.
mosquitto  | 1710016651: For more details see https://mosquitto.org/documentation/authentication-methods/
mosquitto  | 1710016651: Opening ipv4 listen socket on port 1883.
mosquitto  | 1710016651: Opening ipv6 listen socket on port 1883.
mosquitto  | 1710016651: mosquitto version 2.0.18 running
frigate    | s6-rc: info: service s6rc-fdholder: starting
frigate    | s6-rc: info: service s6rc-oneshot-runner: starting
frigate    | s6-rc: info: service s6rc-oneshot-runner successfully started

It was not picking up the custom mosquitto config I had created until I changed the docker compose to:

version: "3.9"
services:
  frigate:
    container_name: frigate
    restart: unless-stopped
    image: ghcr.io/blakeblackshear/frigate:stable
    volumes:
      - ./config:/config
      - ./storage:/media/frigate
      - type: tmpfs # Optional: 1GB of memory, reduces SSD/SD Card wear
        target: /tmp/cache
        tmpfs:
          size: 1000000000
    ports:
      - 5000:5000
      - 8554:8554
  mosquitto:
    image: eclipse-mosquitto
    container_name: mosquitto
    restart: unless-stopped
    network_mode: host
    volumes:
      - ./mosquitto/config:/mosquitto/config
      - ./mosquitto/data:/mosquitto/data
      - ./mosquitto/log:/mosquitto/log
    ports:
      - 1883:1883
      - 9001:9001

The volume - ./mosquitto/config:/mosquitto/config overrides the default config values. For example the below files now override those that were in the /mosquitto/config directory by default

./mosquitto/config/mosquitto.conf

persistence true
persistence_location /mosquitto/data/
log_dest file /mosquitto/log/mosquitto.log

listener 1883
allow_anonymous false
password_file /mosquitto/config/mosquitto.pwd

. /mosquitto/config/mosquitto.pwd

myusername:$7$101$Mencrypted gobble dee gook password==

Using log_dest file /mosquitto/log/mosquitto.log now means you'll need to check logs at sudo tail ./mosquitto/log/mosquitto.log. The default was log_dest stderr hence why you see it in the log stream when running docker compose up initially

nerdosity commented 6 months ago

It's happening the same to me. No log details, even with mqtt debug enabled.

Relevant config:

mqtt:
  enabled: true
  host: 192.168.0.1
  port: 1883
#  topic_prefix: frigate
#  client_id: frigate
  user: homeassistant
  password: REDACTED (same for every MQTT enabled device)
  stats_interval: 60
#  tls_ca_certs:
  # Optional: tls_client_cert and tls_client key in order to use self-signed client
  # certificates (default: None)
  # NOTE: certificate must not be password-protected
  #       do not set user and password when using a client certificate
#  tls_client_cert:
#  tls_client_key:
  # Optional: tls_insecure (true/false) for enabling TLS verification of
  # the server hostname in the server certificate (default: None)
#  tls_insecure:

logger:
  default: info
  logs:
    frigate.comms.mqtt: debug
2024-04-24 14:40:24.395746103  [INFO] Preparing Frigate...
2024-04-24 14:40:24.612619677  [INFO] Starting Frigate...
2024-04-24 14:40:27.375142851  [2024-04-24 14:40:27] frigate.app                    INFO    : Starting Frigate (0.13.2-6476f8a)
2024-04-24 14:40:32.576751036  [2024-04-24 14:40:32] peewee_migrate.logs            INFO    : Starting migrations
2024-04-24 14:40:32.581112665  [2024-04-24 14:40:32] peewee_migrate.logs            INFO    : There is nothing to migrate
2024-04-24 14:40:32.594340669  [2024-04-24 14:40:32] frigate.app                    INFO    : Recording process started: 459
2024-04-24 14:40:32.596854967  [2024-04-24 14:40:32] frigate.app                    INFO    : go2rtc process pid: 89
2024-04-24 14:40:32.615100126  [2024-04-24 14:40:32] detector.coral_pci             INFO    : Starting detection process: 469
2024-04-24 14:40:32.632916695  [2024-04-24 14:40:32] frigate.app                    INFO    : Output process started: 471
2024-04-24 14:40:32.640134541  [2024-04-24 14:40:32] frigate.detectors.plugins.edgetpu_tfl INFO    : Attempting to load TPU as pci
2024-04-24 14:40:32.644727828  [2024-04-24 14:40:32] frigate.detectors.plugins.edgetpu_tfl INFO    : TPU found
2024-04-24 14:40:32.654141696  [2024-04-24 14:40:32] frigate.app                    INFO    : Camera processor started for giardino: 495
2024-04-24 14:40:32.658990841  [2024-04-24 14:40:32] frigate.app                    INFO    : Camera processor started for salone: 496
2024-04-24 14:40:32.665787681  [2024-04-24 14:40:32] frigate.app                    INFO    : Capture process started for giardino: 497
2024-04-24 14:40:32.671435635  [2024-04-24 14:40:32] frigate.app                    INFO    : Capture process started for salone: 502
2024-04-24 14:40:35.257010238  [2024-04-24 14:40:35] frigate.comms.mqtt             ERROR   : Unable to publish to giardino/all: client is not connected
2024-04-24 14:40:35.257326396  [2024-04-24 14:40:35] frigate.comms.mqtt             ERROR   : Unable to publish to giardino/motion: client is not connected
2024-04-24 14:40:35.258455414  [2024-04-24 14:40:35] frigate.comms.mqtt             ERROR   : Unable to publish to giardino_interno/all: client is not connected
2024-04-24 14:40:35.258536063  [2024-04-24 14:40:35] frigate.comms.mqtt             ERROR   : Unable to publish to vialetto_esterno/all: client is not connected
2024-04-24 14:40:35.258604935  [2024-04-24 14:40:35] frigate.comms.mqtt             ERROR   : Unable to publish to balcone/all: client is not connected
2024-04-24 14:40:35.648920641  [2024-04-24 14:40:35] frigate.comms.mqtt             ERROR   : Unable to publish to salone/all: client is not connected
2024-04-24 14:40:35.649180239  [2024-04-24 14:40:35] frigate.comms.mqtt             ERROR   : Unable to publish to salone/motion: client is not connected
2024-04-24 14:41:34.699570752  [2024-04-24 14:41:34] frigate.comms.mqtt             ERROR   : Unable to publish to giardino/motion: client is not connected
2024-04-24 14:41:43.362561063  [2024-04-24 14:41:43] frigate.comms.mqtt             ERROR   : Unable to publish to stats: client is not connected
2024-04-24 14:41:57.631799707  [2024-04-24 14:41:57] frigate.comms.mqtt             ERROR   : Unable to publish to giardino/motion: client is not connected
2024-04-24 14:42:43.904554090  [2024-04-24 14:42:43] frigate.comms.mqtt             ERROR   : Unable to publish to stats: client is not connected
2024-04-24 14:43:44.447075947  [2024-04-24 14:43:44] frigate.comms.mqtt             ERROR   : Unable to publish to stats: client is not connected
2024-04-24 14:44:44.986375043  [2024-04-24 14:44:44] frigate.comms.mqtt             ERROR   : Unable to publish to stats: client is not connected
2024-04-24 14:45:45.565571027  [2024-04-24 14:45:45] frigate.comms.mqtt             ERROR   : Unable to publish to stats: client is not connected
2024-04-24 14:46:07.896044551  [2024-04-24 14:46:07] frigate.comms.mqtt             ERROR   : Unable to publish to giardino/motion: client is not connected
2024-04-24 14:46:23.854744303  [2024-04-24 14:46:23] frigate.comms.mqtt             ERROR   : Unable to publish to giardino/motion: client is not connected
2024-04-24 14:46:46.105557119  [2024-04-24 14:46:46] frigate.comms.mqtt             ERROR   : Unable to publish to stats: client is not connected
2024-04-24 14:47:46.644344673  [2024-04-24 14:47:46] frigate.comms.mqtt             ERROR   : Unable to publish to stats: client is not connected
2024-04-24 14:47:55.641340015  [2024-04-24 14:47:55] frigate.comms.mqtt             ERROR   : Unable to publish to giardino/motion: client is not connected
2024-04-24 14:48:47.190469340  [2024-04-24 14:48:47] frigate.comms.mqtt             ERROR   : Unable to publish to stats: client is not connected
2024-04-24 14:49:01.226477389  [2024-04-24 14:49:01] frigate.comms.mqtt             ERROR   : Unable to publish to giardino/motion: client is not connected
2024-04-24 14:49:47.725503208  [2024-04-24 14:49:47] frigate.comms.mqtt             ERROR   : Unable to publish to stats: client is not connected
2024-04-24 14:49:55.815571802  [2024-04-24 14:49:55] frigate.comms.mqtt             ERROR   : Unable to publish to giardino/motion: client is not connected
2024-04-24 14:50:13.236219231  [2024-04-24 14:50:13] frigate.comms.mqtt             ERROR   : Unable to publish to giardino/motion: client is not connected
2024-04-24 14:50:48.269628118  [2024-04-24 14:50:48] frigate.comms.mqtt             ERROR   : Unable to publish to stats: client is not connected
nerdosity commented 6 months ago

Log from my mosquitto instance:

root@UNAS:~# cat /mnt/user/appdata/mosquitto/log/mosquitto.log 
1713962965: mosquitto version 2.0.18 starting
1713962965: Config loaded from /mosquitto-unraid/include_dir.conf.
1713962965: Opening ipv4 listen socket on port 1883.
1713962965: Opening ipv6 listen socket on port 1883.
1713962965: mosquitto version 2.0.18 running
1713962965: New connection from 192.168.1.20:63751 on port 1883.
1713962965: New client connected from 192.168.1.20:63751 as 7060d64c9be349b98e986e92ce98a336 (p2, c1, k30, u'homeassistant').
1713962965: New connection from 192.168.1.208:47212 on port 1883.
1713962965: New client connected from 192.168.1.208:47212 as mosqsub|385-DAFANG (p1, c1, k60, u'homeassistant').
1713962965: New connection from 192.168.0.144:50465 on port 1883.
1713962965: New client connected from 192.168.0.144:50465 as 3Pg7EITFEb35SB7ON0zE1C (p2, c1, k60, u'homeassistant').
1713962970: New connection from 192.168.2.5:50745 on port 1883.
1713962970: New client connected from 192.168.2.5:50745 as nukihub (p2, c0, k15, u'homeassistant').

Frigate is on 192.168.3.2, it seems that it never even try to connect to MQTT.

NickM-27 commented 6 months ago

more likely that it tries but can't reach it

nerdosity commented 6 months ago

more likely that it tries but can't reach it

Do you have any idea on that? Both are dockerized, my network is on a 255.255.252.0 netmask (I have a lot of devices and it helps me managing them mnemonically), on unraid I regularly have a correct 192.168.0.1 / 22 on network settings.

https://rst.im/ip/192.168.0.1/22 Should manage from 192.168.0.1 up to 192.168.3.254. Frigate is on 192.168.3.2. Devices from 192.168.2.x and 192.168.1.x and from 192.168.0.x works regularly.

NickM-27 commented 6 months ago

what is the config?

nerdosity commented 6 months ago

what is the config? Entire config below. I'm now tweaking detection min and max size, and I realized that it doesn't send nothing to HASS from quite a time.


ui:
  use_experimental: true
  live_mode: mse

mqtt:
  enabled: true
  host: 192.168.0.1
  port: 1883
#  topic_prefix: frigate
#  client_id: frigate
  user: homeassistant
  password: REDACTED
  stats_interval: 60
#  tls_ca_certs:
  # Optional: tls_client_cert and tls_client key in order to use self-signed client
  # certificates (default: None)
  # NOTE: certificate must not be password-protected
  #       do not set user and password when using a client certificate
#  tls_client_cert:
#  tls_client_key:
  # Optional: tls_insecure (true/false) for enabling TLS verification of
  # the server hostname in the server certificate (default: None)
#  tls_insecure:
  tls_ca_certs: /etc/ssl/certs/ca-certificates.crt #checked and this file exists
  tls_insecure: true #I tried to play with both lines, made no differences

logger:
  default: info
  logs:
    frigate.comms.mqtt: debug

birdseye:
  # Optional: Enable birdseye view (default: shown below)
  enabled: false

detectors:
  coral_pci:
    type: edgetpu
    device: pci

ffmpeg:
  global_args: -hide_banner -loglevel info
  hwaccel_args: -hwaccel vaapi -hwaccel_device /dev/dri/renderD128 -hwaccel_output_format
    yuv420p
  input_args: -avoid_negative_ts make_zero -fflags +genpts+discardcorrupt -rtsp_transport
    tcp -stimeout 5000000 -use_wallclock_as_timestamps 1
  output_args:
    detect: -f rawvideo -pix_fmt yuv420p -an
#    record: -f segment -segment_format mp4 -segment_time 10 -reset_timestamps 1 -strftime
#      1 -codec:v h264_vaapi -global_quality 50 -b:v 2M -maxrate 2M -codec:a copy

go2rtc:
  streams:
    giardino_hq: # <- for RTSP streams
    - rtsp://admin:REDACTED@192.168.2.10:554//h265Preview_01_main   # <- stream which supports video & aac audio
    - ffmpeg:giardino_hq#audio=opus#video=h265/rk     # <- copy of the stream which transcodes audio to the missing codec (usually will be opus)
#    - ffmpeg:giardino_hq#audio=opus
    giardino_lq:
    - rtsp://admin:REDACTED@192.168.2.10:554//h264Preview_01_sub
    - ffmpeg:giardino_lq#audio=opus     # <- copy of the stream which transcodes audio to the missing codec (usually will be opus)
    salone_hq:
    - rtsp://admin:REDACTED@192.168.2.9:554//h264Preview_01_main
    - ffmpeg:salone_hq#audio=opus     # <- copy of the stream which transcodes audio to the missing codec (usually will be opus)
#    salone_mq:
#      -  rtsp://admin:REDACTED@192.168.2.9:554//h264Preview_01_ext
#      - "ffmpeg:salone_mq#audio=opus" # <- copy of the stream which transcodes audio to the missing codec (usually will be opus)      
    salone_lq:
    - rtsp://admin:REDACTED@192.168.2.9:554//h264Preview_01_sub
    - ffmpeg:salone_lq#audio=opus     # <- copy of the stream which transcodes audio to the missing codec (usually will be opus)  

cameras:
  giardino:
    motion:
      mask:
      - 310,35,185,36,185,0,314,0
      - 1536,0,1536,328,1492,378,1305,245,1267,221,1319,113,1156,0,1276,0
      - 1013,44,773,0,1152,0,1324,114,1269,230
      - 359,0,228,74,247,113,642,0
      - 89,293,274,164,229,75,356,0,0,0,0,182
    ffmpeg:
      inputs:
      - path: rtsp://127.0.0.1:8554/giardino_lq
        input_args: preset-rtsp-restream
        roles:
        - detect
      - path: rtsp://127.0.0.1:8554/giardino_hq
        input_args: preset-rtsp-restream
        roles:
        - record
    live:
      stream_name: Giardino
#        hwaccel_args:
#          -hwaccel vaapi
#          -hwaccel_device /dev/dri/renderD128
#          -hwaccel_output_format vaapi
    objects:
      track:
      - person
      - dog
      - cat
      - bird
      - rat
      filters:
        person:
          min_score: 0.4
          threshold: 0.7
          min_area: 500
          max_area: 25000
          min_ratio: 0.5
          max_ratio: 2.0
        dog:
          min_score: 0.4
          threshold: 0.7
          min_area: 200
          max_area: 5000
          min_ratio: 0.5
          max_ratio: 1.5
        cat:
          min_score: 0.4
          threshold: 0.7
          min_area: 200
          max_area: 5000
          min_ratio: 0.5
          max_ratio: 1.5

    zones:
      giardino_interno:
        coordinates: 
          464,444,662,481,921,475,1207,402,1303,378,1292,274,1118,147,1043,110,1001,103,1008,80,953,72,946,94,780,74,775,47,597,61,599,89,523,98,246,393
        filters:
          person:
            min_area: 1000
            max_area: 30000
          dog:
            min_area: 250
            max_area: 5000
      vialetto_esterno:
        coordinates: 
          528,98,594,85,600,59,772,62,785,78,955,103,956,76,1001,92,1003,103,1049,111,1122,158,1132,138,1047,79,937,0,787,0,675,0,584,0,446,21,237,101,161,148,36,213,151,360,251,384
        filters:
          person:
            min_area: 150
            max_area: 2500
          dog:
            min_area: 50
            max_area: 700
      balcone:
        coordinates: 0,576,1536,576,1536,328,1273,207,1198,336,367,341,294,201,0,367
        filters:
          person:
            min_area: 8000
            max_area: 100000
          dog:
            min_area: 1000
            max_area: 50000

  salone:
    motion:
      mask:
      - 0,10,0,21,195,21,193,10
    ffmpeg:
      inputs:
      - path: rtsp://127.0.0.1:8554/salone_lq
        input_args: preset-rtsp-restream
        roles:
        - detect
      - path: rtsp://127.0.0.1:8554/salone_hq
        input_args: preset-rtsp-restream
        roles:
        - record

    live:
      stream_name: Salone
    objects:
      track:
      - person
      - dog
      filters:
        person:
          min_score: 0.5
          threshold: 0.7
          min_area: 1500
          max_area: 20000
          min_ratio: 0.5
          max_ratio: 2.0
        dog:
          min_score: 0.5
          threshold: 0.7
          min_area: 1000
          max_area: 15000
          min_ratio: 0.5
          max_ratio: 2.0

record:
  enabled: true
  expire_interval: 60
  retain:
    days: 7
    mode: all

objects:
  track:
  - person
  - dog
  - cat
  - bird
  - rat

  filters:
    dog:
      min_area: 5000
      max_area: 75000
      threshold: 0.6
    cat:
      min_area: 3000
      max_area: 50000
      threshold: 0.6
    bird:
      min_area: 1000
      max_area: 30000
      threshold: 0.65
    rat:
      min_area: 500
      max_area: 15000
      threshold: 0.7

snapshots:
  enabled: true
  timestamp: false
  bounding_box: true
  crop: false
  required_zones: []
  retain:
    default: 10
    objects:
      person: 15
imanbakker commented 6 months ago

are you also running it inside truenas scale? and updated to dragonfish today? It took me a while but i am fairly certain the problem originates form on the truenass/frigate side in my case. i tried deploying a new docker inside docker with an older version of frigate (truecharts) and that also doesn't work.

so i am guessing the combination Truenas scale: dragonfish and frigate isnt working properly on the network side but i cant figure out where it is going wrong. unfortunatly i cannot rollback my truenas scale installation..

nerdosity commented 6 months ago

are you also running it inside truenas scale? and updated to dragonfish today? It took me a while but i am fairly certain the problem originates form on the truenass/frigate side in my case. i tried deploying a new docker inside docker with an older version of frigate (truecharts) and that also doesn't work.

so i am guessing the combination Truenas scale: dragonfish and frigate isnt working properly on the network side but i cant figure out where it is going wrong. unfortunatly i cannot rollback my truenas scale installation..

nope, it's a unRAID custom machine. https://hub.docker.com/r/cmccambridge/mosquitto-unraid/ and https://hub.docker.com/r/blakeblackshear/frigate/

EDIT: I removed the docker and recreated, it forced an update, now the docker repo is different, is https://github.com/blakeblackshear/frigate/pkgs/container/frigate

Still,


024-04-24 16:41:05.434831884  [2024-04-24 16:41:05] frigate.app                    INFO    : Capture process started for salone: 500
2024-04-24 16:41:08.437416006  [2024-04-24 16:41:08] frigate.comms.mqtt             ERROR   : Unable to publish to salone/all: client is not connected
2024-04-24 16:41:08.437690973  [2024-04-24 16:41:08] frigate.comms.mqtt             ERROR   : Unable to publish to salone/motion: client is not connected
2024-04-24 16:41:09.399305826  [2024-04-24 16:41:09] frigate.comms.mqtt             ERROR   : Unable to publish to giardino/all: client is not connected
2024-04-24 16:41:09.399695420  [2024-04-24 16:41:09] frigate.comms.mqtt             ERROR   : Unable to publish to giardino/motion: client is not connected
2024-04-24 16:41:09.399788899  [2024-04-24 16:41:09] frigate.comms.mqtt             ERROR   : Unable to publish to giardino_interno/all: client is not connected
2024-04-24 16:41:09.399938492  [2024-04-24 16:41:09] frigate.comms.mqtt             ERROR   : Unable to publish to vialetto_esterno/all: client is not connected
2024-04-24 16:41:09.400229990  [2024-04-24 16:41:09] frigate.comms.mqtt             ERROR   : Unable to publish to balcone/all: client is not connected
2024-04-24 16:42:16.110856411  [2024-04-24 16:42:16] frigate.comms.mqtt             ERROR   : Unable to publish to stats: client is not connected
nerdosity commented 6 months ago

image I run this from the shell, and it's unable to connect to 192.168.0.1.

Any suggestions?

Edit: I think that I traced down the issue.

Frigate cannot access stuff on a different IP class. MQTT server is now on 192.168.3.5, frigate is on 192.168.3.2, and MQTT error disappeared.

But it's an entire big network, from 192.168.0.x to 192.168.3.x, I am slowly putting every DHCP static address on the right part. Now every VM and docker is on 192.168.3.x, so it started working.

But my NUKI hub can access 192.168.3.5 for MQTT, even if it's a physical device in the 192.168.1.x range.

silvioped commented 4 months ago

In my case, in the frigate configuration yaml, removing the :1883 in the "host: " solved the problem.

pypeaday commented 4 months ago

I ran into this today but my issue was pretty simple - mqtt is running on home assistant, but my home assistant VM IP changed on reboot (silly me) so my frigate config was pointing to wrong IP. Simple problem but took me quite a while to diagnose