kerberos-io / agent

An open and scalable video surveillance system for anyone making this world a better and more peaceful place.
https://kerberos.io
MIT License
642 stars 78 forks source link

mqtt message - Double slash #84

Closed Hooch76 closed 1 year ago

Hooch76 commented 1 year ago

Hi,

I can see that the Kerberos agent is using the following MQTT topic

kerberos//device/...

I would have expected that it would be

kerberos/device/...

(notice the difference between one and two slashes)

Is this correct or a bug?

Thanks, Tom

cedricve commented 1 year ago

This is related to the upload issue with missing credentials! Thanks for reporting. If no credentials are set, no outgoing MQTT session should be made to Hub as well!

cedricve commented 1 year ago

Hey @Hooch76, I just had a look and it should not open any outgoing MQTT missages if the hubkey is not set. https://github.com/kerberos-io/agent/blob/master/machinery/src/routers/mqtt/main.go#L62

Can you validate your config, and the version of your Kerberos Agent?

Hooch76 commented 1 year ago

I am using d9694ac and a local MQTT server:

Sending PUBLISH to (d0, q0, r0, m0, 'kerberos//device/cam_front_door/motion', ... (6 bytes))

My local MQTT server is configured under Settings > Streaming: Broker URI, Username and Password.

cedricve commented 1 year ago

Ok thanks for the feedback! Will verify that.

cedricve commented 1 year ago

This has been fixed by https://github.com/kerberos-io/agent/commit/71cd315142a97f56596bfe3b56a3c5aadb45d592. Thanks for reporting @Hooch76

Hooch76 commented 1 year ago

Just a question: now I am using

image: "kerberos/agent:71cd315"

Nothing is configured in the "Kerberos Hub", "Persistence" and "STUN/TURN" sections, but I've configured MQTT (Broker URI (which points to my own MQTT server), Username and Password). Offline mode is disabled. This does no longer trigger a MQTT message when motion is detected (which is bad because I was using MQTT to kick off stuff in Home Assistant). MQTT messages were sent in https://github.com/kerberos-io/agent/releases/tag/d9694ac though.

Is this a configuration error on my side or a bug?

cedricve commented 1 year ago

Good point! I didn't get the usecase, apologies. Now I understand the underlaying question. When bringing your own MQTT broker, without connecting to Kerberos Hub, you still want to receive motion messages on your own broker. Therefore we cannot disable the MQTT messages on motion (what we did now).

As you suggested earlier, I propose the following:

Kerberos Hub connected -> Motion -> kerberos/${hubkey}/device/${devicekey}... No Kerberos Hub connected -> Motion -> kerberos/device/${devicekey}...

Hooch76 commented 1 year ago

Kerberos Hub connected -> Motion -> kerberos/${hubkey}/device/${devicekey}... No Kerberos Hub connected -> Motion -> kerberos/device/${devicekey}...

Sounds good (if you were asking me ;-) )

cedricve commented 1 year ago

fixed in latest release! https://github.com/kerberos-io/agent/blob/master/machinery/src/computervision/main.go#L167-L173

Hooch76 commented 1 year ago

Works perfectly fine. Thank you!