Connection to MQTT server failed : getaddrinfo() argument 2 must be integer or string #1450

pull/1452/head
nicolargo 2019-03-31 11:02:36 +02:00
parent 6f5ea9592d
commit 2030adf58a
2 changed files with 9 additions and 5 deletions

View File

@ -413,6 +413,7 @@ port=8883
user=guest
password=guest
topic=glances
tls=true
[couchdb]
# Configuration for the --export couchdb option

View File

@ -42,20 +42,22 @@ class Export(GlancesExport):
self.user = None
self.password = None
self.topic = None
self.tls = 'true'
# Load the MQTT configuration file
self.export_enable = self.load_conf('mqtt',
mandatories=['host', 'password'],
options=['port', 'user', 'topic'])
options=['port', 'user', 'topic', 'tls'])
if not self.export_enable:
exit('Missing MQTT config')
# Get the current hostname
self.hostname = socket.gethostname()
self.port = self.port or 8883
self.port = int(self.port) or 8883
self.topic = self.topic or 'glances'
self.user = self.user or 'glances'
self.tls = (self.tls.lower() == 'true')
# Init the MQTT client
self.client = self.init()
@ -69,6 +71,7 @@ class Export(GlancesExport):
clean_session=False)
client.username_pw_set(username=self.user,
password=self.password)
if self.tls:
client.tls_set(certs.where())
client.connect(host=self.host,
port=self.port)