thin-edge.io icon indicating copy to clipboard operation
thin-edge.io copied to clipboard

thin-edge health-check not functioning when mqtt bind address is changed

Open gligorisaev opened this issue 2 years ago • 3 comments

Describe the bug thin-edge health-check not functioning when mqtt bind address is changed

To Reproduce

Preconditions

  • thin-edge is installed on DUT
  • DUT is connected to c8y
  • tedge-mapper-c8y.service file is updated with WatchdogSec+30
  • Subscribed to tedge/health tedge mqtt sub tedge/health/#
  • The expected payload is received as expected
  • Unsubdscribed from mqtt with Ctrl+c

Steps to reproduce

  1. Change the MQTT bind address sudo tedge config set mqtt.bind_address XXX.XXX.XXX.XXX
  2. Disconnect from c8y sudo tedge disconnect c8y
  3. Connect to c8y sudo tedge connect c8y
  4. Check the tedge settings tedge config list and observe that the mqtt.bind_address is changed to the address from Step 2
  5. Subscribe to tedge/health tedge mqtt sub tedge/health/#

Observe that no messages will be received

Expected behavior Health messages to be received as before the bind address change

Screenshots

Environment (please complete the following information):

  • OS [incl. version]
  • Hardware [incl. revision]
  • System-Architecture: Linux raspberrypi 5.15.32-v8+ #1538 SMP PREEMPT Thu Mar 31 19:40:39 BST 2022 aarch64 GNU/Linux
  • thin-edge.io version 0.7.4

Additional context

gligorisaev avatar Aug 31 '22 06:08 gligorisaev

Can you tell which services are up on your device? Only tedge-mapper-c8y and tedge-agent?

If you have other services like tedge-mapper-collectd, c8y-log-plugin, those are not managed by tedge connect, if you change the MQTT address, you need to restart those services. Otherwise, their mqtt clients cannot know the address change.

rina23q avatar Aug 31 '22 14:08 rina23q

In order to connect to thin-edge MQTT bus, you have to use the external mqtt address

When you configure an external address with:

sudo tedge config set mqtt.external.bind_address XXX.XXX.XXX.XXX

then thin-edge is accessible from two different addresses:

  • The thin-edge components use the localhost interface.
  • While child-devices and other systems (for instance the tests) use the mqtt.external.bind_address.

The use of mqtt.bind_address is very specific. This is when a thin-edge component is not deployed on the same host as the mosquitto server. For instance, if the mapper is running in a container, this mapper must be configured with a mqtt.bind_address set to the mqtt.external.bind_address of the main thin-edge box where mosquitto is running.

=> I see this as a documentation bug. A visual representation might help a lot here as suggested by https://github.com/thin-edge/thin-edge.io/issues/1238.

didier-wenzek avatar Sep 01 '22 08:09 didier-wenzek

In order the new bind address to be working the relevant service needs to be restarted after change is made. The How to: https://thin-edge.github.io/thin-edge.io/html/howto-guides/008_config_local_mqtt_bind_address_and_port.html is outdated and missleading. My expectation would be that with propper change of the How to guide this bug could be closed

gligorisaev avatar Sep 21 '22 11:09 gligorisaev

The bug is no longer applicable as of 0.10.0

reubenmiller avatar Mar 28 '23 09:03 reubenmiller