[FIX] iot: check the URL before lauch the ws client
Add a condition that check if the DB is connected to the iot box before the start of the websocket client, before, if no DB was connected the Thread was lauched for nothing closes odoo/odoo#143132 Signed-off-by: Yaroslav Soroko (yaso) <yaso@odoo.com>
This commit is contained in:
@@ -26,7 +26,7 @@ iot_devices = {}
|
||||
|
||||
|
||||
class Manager(Thread):
|
||||
def send_alldevices(self, iot_client):
|
||||
def send_alldevices(self, iot_client=None):
|
||||
"""
|
||||
This method send IoT Box and devices informations to Odoo database
|
||||
"""
|
||||
@@ -67,7 +67,8 @@ class Manager(Thread):
|
||||
'Accept': 'text/plain',
|
||||
},
|
||||
)
|
||||
iot_client.iot_channel = json.loads(resp.data).get('result', '')
|
||||
if iot_client:
|
||||
iot_client.iot_channel = json.loads(resp.data).get('result', '')
|
||||
except Exception as e:
|
||||
_logger.error('Could not reach configured server')
|
||||
_logger.error('A error encountered : %s ' % e)
|
||||
@@ -104,7 +105,8 @@ class Manager(Thread):
|
||||
_logger.error("Error in %s: %s", str(interface), e)
|
||||
|
||||
#Setup the websocket connection
|
||||
iot_client.start()
|
||||
if helpers.get_odoo_server_url():
|
||||
iot_client.start()
|
||||
# Check every 3 secondes if the list of connected devices has changed and send the updated
|
||||
# list to the connected DB.
|
||||
self.previous_iot_devices = []
|
||||
|
||||
Reference in New Issue
Block a user