agent icon indicating copy to clipboard operation
agent copied to clipboard

agent stop to relay messages to nats when disconnects and reconnects to mqtt

Open pricelessrabbit opened this issue 4 years ago • 0 comments

steps to reproduce

  1. start the agent and send commands from a mainflux instance
  2. simulate a connection issue and wait agent to notify the disconnection
  3. re-enable the connection and wait agent to notify the reconnection

expected

commands and service messages (channels//services/# ) are managed by agent and relayed into the local nats bus

actual

agent stops to relay commands until the service is restarted


imo the issue is related to the Paho clean session flag that is set to "true" in the config. when paho disconnects and auto reconnects, seems that it does not re-subscribe to the mqtt topics that the broker has wiped out when client disconnected. In fact, when changing clean session to false, the agent works as expected.

Are there any drawbacks in setting the session as persistent (clean session = false)? If not i can open a PR. A more involed solution is to use the paho handlers to re-subscribe to the topics when connection is lost. If a clean session is needed when the service process starts / restarts, there is also this workaround to have a cleaned persistent session

pricelessrabbit avatar Jan 25 '21 15:01 pricelessrabbit