I’m pretty much getting at my wit’s end. I’m trying to make frigate connect to Mosquitto broker add-on in HomeAssistant, but all I get is the following error in Frigate:
frigate.comms.mqtt ERROR : Unable to publish to kitchen/all: client is not connected
frigate.comms.mqtt ERROR : Unable to publish to zone_0/all: client is not connected
frigate.comms.mqtt ERROR : Unable to publish to stats: client is not connected
I’m running HA OS in a VM on a Truenas SCALE server (both reachable through a cloudflare tunnel and local IP), Frigate is installed as an app on Truenas. Both are reachable through their respective IP’s as in VM_IP:8123 for HA and TRUENAS_IP:10500 for Frigate.
The HA versions are:
Core 2024.2.2
Supervisor 2024.01.1
Operating System 11.5
Frontend 20240207.1
After configuring Frigate with the the following config, it is unable to find the broker
I’ve tried with different users (default HA user, created a new frigate user in HA, added login to Mosquitto add-on), but the same error message keeps popping up.
When testing with MQTT Explorer, the broker is perfectly reachable with every single one of the users.
Getting tired of trying endless possibilities which all won’t work I decided to take another route and create a new Mosquitto broker as a Truenas app, so everything can connect to that one. I created multiple users in the new broker. Frigate connected perfectly fine, but HA refuses to connect to that broker and just says Failed to connect. Setting “Broker certificate validation” to Auto also didn’t help trying to connect.
Both HA and Frigate really aren’t giving any help with the error messages and I can’t find out what’s blocking the connections both in or out.
Can you verify that you can connect and publish to mosquitto using your credentials via mqtt explorer ?
I connected with each user without problem through MQTT Explorer. Will try if publishing works in an hour or so when I get home.
WAIT - what does this mean ?
Are both hosts on the same network ?
It’s one device running Truenas. HA runs inside a VM, which gives it a different IP address than the Truenas server. Frigate runs as a Truenas (Truecharts) app, which gives it the same IP address as the Truenas server, but listens on its own ports.
So HA has 192.168.x.x, Truenas has 192.168.x.y and Frigate can be reached through 192.168.x.y:10500
Random thought - are clients setup using explicit IPv4 or via DNS names?
I’ve seen a lovely issue where MQTT Explorer / mosquitto_sub was using explicit IPv4, but a device was using a mDNS / DNS name which happened to resolve to IPv6. The HAOS VM didn’t used to support IPv6 causing subtle MQTT failures…
Tends to only happen on server OS as embedded kit like Tasmota is too small to use mDNS and IPv6 dual-stack.
Once you can test a connection via IPv4 from a separate machine, Mosquitto on HAOS is pretty bullet proof. Here’s a link to some ideas if you can’t connect or get authentication errors in the logs (the Tasmota & discovery stuff is less relevant):
Nice - finger memory still types telnet host 1883 even through it’s not been installed for years.
Netcat is a better replacement for “living off the land”, although again, I’d suggest trying explicit IPv4 addresses for the broker just in case of IPv6…
I agree, you have a point about ipv4/6 but @JobKlimop is explicitly using ipv4 addresses and not hostnames so this shouldn’t be an issue unless of course everything is listening on an ipv6 interface which we’re all unaware of
Lets rule that one - @JobKlimop can you confirm that you can connect to ha using ipv4 ie
I can connect to HA using IPv4, as well as truenas. Interestingly enough, using nc -v 192.168.x.x 1883 in the Truenas shell results in nc: connect to 192.168.x.x port 1883 (tcp) failed: No route to host.
Yet, when I use Nmap from a different device, it can find that port just fine. Discovered open port 1883/tcp on 192.168.x.x
@FloatingBoater I’m not very familiar with telnet, but the command results in an empty cmd window (windows)
It looks like there’s a blockade between Truenas and the VM it runs.
Publishing through MQTT explorer worked just fine by the way
HAOS+MQTT Frigate
| |
----------------
(*) VM router
PC NAS
| |
--------LAN------------(*) WAN Router---INet---Cloudflare
PC - LAN - VM - MQTT = IPv4 AOK? (e.g MQTT Explorer)
PC - LAN - VM - Frigate = IPv4 AOK?
Frigate - VM - HAOS = IPv4 No route?
My guess is there’s an IP route missing between the NAS virtual machine router internal virtual interfaces / IP addresses (may be a different internal IPv4 subnet - that’s how HAOS Docker does it).
Alright, that got me a bit further!
Your drawing is pretty much on point.
I had to create a bridge in Truenas linking to the IP of Truenas and attach that to the NIC of the VM.
(For anyone following the same route as I am, this video and this post on the Truenas forum helped me a lot. Keep console open for error messages when editing the network adapters, since the UI won’t show them)
If I run nc -v 192.168.x.x 1883 now it responds with Connection to 192.168.1.203 1883 port [tcp/*] succeeded!
And just to be sure I also pinged the Truenas IP from withing the HA VM, which also makes a connection
So, that’s a good start! I’m still having troubles with Frigate still throwing the same error though.
Well, I did it! Not exactly the way I wanted, and not sure if I will keep it like this, but for now it works.
So the way to get it to work for me in the end, was by setting up a mosquitto broker on Truenas and connecting HA, Z2M and Frigate to that one. Frigate really didn’t want to connect to them Mosquitto broker add-on in HA, which might be cause by a little buggy certificate handling.
Also, Z2M really didn’t want to connect to the external broker with the “addons” user for me (even though creating one). But I was able to use any other user I created just fine.
The next bump I hit was with the integration. I ran into 2 issues in this step:
Frigate doesn’t open port 5000 to reach the API
The Frigate Truecharts release apparently is an older version, which the latest HACS integration doesn’t support
So, after installing the integration and trying to connect to frigate I got and error message that it couldn’t connect. Which is because port 5000 isn’t exposed anymore.
However, it is possible to make a connection to http://192.168.x.x:10500. Apparently the API is reachable through the default port as well.
This resulted in an error that no entities were found, though. By going into the logs I noticed this message: Using a Frigate server with version 0.12.1-367d724 <= 0.12.1 which is not compatible
For now I got it running by installing version 4.0.1 of the Frigate integration in HACS. Be aware that it might take a couple of tries installing an older version, the first 2 times it installed the latest one for me, even though selecting the older version.
Not sure if I keep it set up this way, with the external Mosquitto broker. I do have the idea that the performance is lacking a little compared to the Mosquitto add-on.
I am currently running in the same issue where homeassistant and frigate wont connect, have you found any other solution than using a external mqtt broker?
Interesting… I’m bumping this if anyone else has issues.
I recently migrated from my podman setup to a more user friendly proxmox setup and I’m now seeing old behaviour where the mqtt port is reachable but mqtt doesn’t route. I’ve got the feeling that this is due to docker routing in HAOS or the addon is screwing with it too