i8beef / HomeAutio.Mqtt.GoogleHome

MIT License
215 stars 29 forks source link

not connecting to mqtt server in 3.x (i.e. dotnet7) releases #140

Closed clmcavaney closed 1 year ago

clmcavaney commented 1 year ago

G'day, I haven't updated my container in a while and thought I would try the 3.x series. But when I do, the service doesn't connect to the mqtt server any more.

homeautio.mqtt.googlehome  | [00:49:27 ERR] Error while connecting with server.
homeautio.mqtt.googlehome  | [00:49:27 INF] Now listening on: http://[::]:5000
homeautio.mqtt.googlehome  | [00:49:27 INF] Application started. Press Ctrl+C to shut down.
homeautio.mqtt.googlehome  | [00:49:27 INF] Hosting environment: Production
homeautio.mqtt.googlehome  | [00:49:27 INF] Content root path: /app
homeautio.mqtt.googlehome  | [00:49:27 INF] Disconnected.
homeautio.mqtt.googlehome  | [00:49:27 INF] MQTT Connection closed unexpectedly, reconnecting...
homeautio.mqtt.googlehome  | [00:49:27 WRN] MQTT Connection failed, retrying...
homeautio.mqtt.googlehome  | [00:49:32 ERR] Error while connecting with server.
homeautio.mqtt.googlehome  | [00:49:32 INF] Disconnected.
homeautio.mqtt.googlehome  | [00:49:32 INF] MQTT Connection closed unexpectedly, reconnecting...
homeautio.mqtt.googlehome  | [00:49:32 WRN] MQTT Connection failed, retrying...
^CGracefully stopping... (press Ctrl+C again to force)

Has there been a change in the mqtt library or something else that could be causing this?

i8beef commented 1 year ago

Did you read the stickied post and change your setup appropriately? https://github.com/i8beef/HomeAutio.Mqtt.GoogleHome/issues/138

clmcavaney commented 1 year ago

Thanks Michael, I did try that but mustn't have got the exact syntax correct. When I did get it working, the logs are a little confusing to me as the first line says:

homeautio.mqtt.googlehome  | [21:27:32 INF] Loaded with configuration from: appsettings.json, /app/config/appsettings.Production.json

Which is different to what is specified in that #138 and subsequently what I put in my docker-compose.yml file:

- "<local path>/etc/google-home/appsettings.Production.json:/app/appsettings.Production.json"

i.e. /app/appsettings.Production.json doesn't match /app/config/appsettings.Production.json

Maybe that file is being copied to the /app/config directory on startup. Not sure.

i8beef commented 1 year ago

That's just the message it spits out, I need to change that (whoops). Your mount looks correct to me. Anything special about your MQTT setup? TLS? Certificate based auth?

clmcavaney commented 1 year ago

Nothing special from where that is connecting (i.e. internal LAN) - not connecting via TLS for that. Once I made that change you mentioned above it is working.

On the question of TLS or cert based auth - I did try and have homeautio.mqtt.googlehome hosted on a cloud VM, but there was issues with it connecting to my MQTT broker. Some issue with the TLS certificates connection, so I have just kept it local.

i8beef commented 1 year ago

So working again?

There is a difference between making a connection to MQTT over TLS (using port 8883 usually) and AUTHENTICATING with a certificate. The underlying library supports both, and I SHOULD expose all the right things to do it, though I had some confusion over it since they merge the settings together a bit so I haven't actually tried cert auth. I DO use TLS connections though, and usually problems there have to do with using self-signed certs, etc., and setting some combination of the cert chain settings to make sure the cert passes.

https://github.com/i8beef/HomeAutio.Mqtt.GoogleHome/wiki/Config:-appsettings.Production.json#mqtt-broker-tls-settings

clmcavaney commented 1 year ago

Yes, working with v3.x with the config change you pointed out. Thanks for that. This issue can now be closed. I will follow up on the MQTT with TLS and auth at a later point.