Browse Source

fix: Update connection loop mechanism

fix/mqtt-connection
Bugra Isguzar 1 year ago
parent
commit
1d62104849
2 changed files with 12 additions and 6 deletions
  1. 1
    1
      agent.py
  2. 11
    5
      core/__init__.py

+ 1
- 1
agent.py View File

@@ -4,7 +4,7 @@ import os
from core import Agent
from configparser import ConfigParser

__version__ = "0.4.1"
__version__ = "0.4.2"

environments_object = ConfigParser()
environments_object.read("/opt/sixfab/.env")

+ 11
- 5
core/__init__.py View File

@@ -69,11 +69,17 @@ class Agent(object):

if not self.is_connected:
logger.debug("[LOOP] Network online, starting mqtt agent")
self.client.connect(
self.configs["environments"].get("MQTT_HOST", MQTT_HOST),
MQTT_PORT,
keepalive=30
)
try:
self.client.connect(
self.configs["environments"].get("MQTT_HOST", MQTT_HOST),
MQTT_PORT,
keepalive=30
)
except:
logger.error("[LOOP] Couldn't start connection loop")
continue

self.client.loop_start()
self.is_connected = True


Loading…
Cancel
Save