gigaset-elements-proxy icon indicating copy to clipboard operation
gigaset-elements-proxy copied to clipboard

Hassio Addon: not connecting to Mosquitto Addon when using loopback IP/Host

Open Pe-MaKer opened this issue 5 years ago • 8 comments

The Mosquitto Broker does not receive MQTT messages from the Gigaset elements proxy.

Setup: Home Assistant 0.100.1 Hassio Supervisor 189 HassOS 2.11 Gigaset Elements Proxy Add-on 1.2 Mosquitto Broker Add-on 5.1

I created a new user "gigaset" in the HA user administration, which I also used in the add-on config of the element Proxy:

{
  "email": "[email protected]",
  "password": "password;)",
  "check_events_interval": 10,
  "mqtt_url": "mqtt://localhost:1883",
  "mqtt_options": {
    "clientId": "gigaset",
    "username": "gigaset",
    "password": "donttellanybody"
  },
  "allow_unknown_events": false
}

The log of the proxy doesn't show any (e.g. authentication) error:

[Tue Oct 22 2019 10:27:26] [LOG]    acquired event: {"id":"9fca34723794fd141241b359e55c41ee2b7976ee","state":"ok","ts":"1571732840809","type":"close","o":{"frontendTags":{"room":{"roomName":"Arbeitszimmer"}},"friendly_name":"Arbeitszimmerfenster","id":"0335ab9b16","factoryType":"umos","type":"um01","umosConfiguredType":{"mainType":"window","subType":"regular"},"room":{"id":75665,"friendlyName":"Arbeitszimmer"}},"source_id":"BB4BC9AAA262EEABA32021A066F0B043","source_name":"base","source_type":"basestation","state_pre":"ok"}
[Tue Oct 22 2019 10:27:26] [LOG]    event sent as mqtt_topic: gigaset/Arbeitszimmerfenster, value: false

But when I subscribe to the topic "gigaset/Arbeitszimmerfenster" or "gigaset/#", nothing happens. No messages, no error messages in the Mosquitto logs. Just nothing.

Pe-MaKer avatar Oct 22 '19 08:10 Pe-MaKer

Try mqtt://localhost instead of mqtt://localhost:1883

h4nc avatar Oct 22 '19 10:10 h4nc

I've tried it without port number with the same result. No messages and unfortunately not even an error message.

Pe-MaKer avatar Oct 22 '19 13:10 Pe-MaKer

You could also try mqtt://yourlocalipadress. But it seems like there is a different issue. I'm sure @ycardon will help you.

h4nc avatar Oct 22 '19 13:10 h4nc

After changing the mqtt_url to my local hostname, it looks promising:

19-10-22 13:48:42 INFO (SyncWorker_15) [hassio.docker.addon] Start Docker add-on d8fd2d64/armv7-addon-gigaset with version 1.2
19-10-22 13:48:47 INFO (MainThread) [hassio.auth] Auth request from core_mosquitto for gigaset
19-10-22 13:48:48 INFO (MainThread) [hassio.auth] Success login from gigaset

:)

"localhost" and "127.0.0.1" (as documented) did not work. One have to specify at least the Hostname or IP of the broker.

Pe-MaKer avatar Oct 22 '19 13:10 Pe-MaKer

Well, it does work with localhost when you are not using it as a Hassio add-on (which uses docker networking: localhost from within a docker container is not the "host" localhost)

I keep the issue open until I put some works in the doc !

ycardon avatar Apr 14 '20 16:04 ycardon

(which uses docker networking: localhost from within a docker container is not the "host" localhost)

@ycardon could you explain that bit more? Is it not the „host“ localhost because it’s not in the same container?

h4nc avatar Apr 14 '20 21:04 h4nc

yes, it could be clearer :)

When you are using docker, you must consider that each container is a (virtual) server.

  • on Hassio architecture, MQTT broker runs inside one container, gigaset-proxy runs inside an other container: everything happens as if they were running on different servers, so you cannot use localhost and must use explicit IP addresses

  • without Hassio, MQTT broker and gigaset-proxy run on the same server so you can use localhost

Better explanation ?

ycardon avatar Apr 15 '20 14:04 ycardon

Better explanation ?

Perfect explanation, thank you!

h4nc avatar Apr 15 '20 18:04 h4nc