fbacker / broadlink-mqtt-bridge

Bridge Broadlink RM Devices with MQTT and API for e.g. OpenHAB
41 stars 14 forks source link

Mqtt reconnect each 30 seconds #29

Closed Majestry closed 4 years ago

Majestry commented 4 years ago

Using the latest version on rpi3b+. OS: openhabian with mosquitto broker. bridge is running as service.

In logs each 30 seconds i see next: 2019-12-17 17:31:27 [error]: MQTT Closed 2019-12-17 17:31:28 [info]: MQTT Reconnected 2019-12-17 17:31:58 [error]: MQTT Closed 2019-12-17 17:31:59 [info]: MQTT Reconnected 2019-12-17 17:32:29 [error]: MQTT Closed

fbacker commented 4 years ago

If you use a MQTT client and connect to the mosquitto. Does it work? Do the connection keep alive?

I'm using

import mqtt from 'mqtt';
this.client = mqtt.connect('', this.options);

The settings from default.json (you can override with a local.json) Se WIKI. Are you using some kund of username, password. Another port or host. Don't really know why it would close and reconnect. Client options: https://www.npmjs.com/package/mqtt#client

"mqtt": {
    "host": "127.0.0.1",
    "port": 1883,
    "protocol": "mqtt",
    "subscribeBasePath": "broadlink/"
  }

Might be that there isn't that much traffic in the bus? try adding keepalive with a longer time than default.

Another thing might be that the first connection fails, and you are seeing the reconnect try

from mqtt docs connectTimeout: 30 * 1000 milliseconds, time to wait before a CONNACK is received

look thru the logs to see the first mqtt connection attempt.

Majestry commented 4 years ago

This is really strange, but now connection to mqtt is not lost after 30 seconds. Sorry for disturbing.