RFLinkGateway
RFLinkGateway copied to clipboard
Question: how to specify username and password for MQTT broker?
I cannot find how to specify the username and passoword for the mqtt broker, I have putt security on the broker and want to user your code to connect.
I found the missing peace of code in MQTTClient.py: class MQTTClient(multiprocessing.Process): def init(self, messageQ, commandQ, config): self.logger = logging.getLogger('RFLinkGW.MQTTClient') self.logger.info("Starting...")
multiprocessing.Process.__init__(self)
self.__messageQ = messageQ
self.__commandQ = commandQ
self.mqttDataPrefix = config['mqtt_prefix']
self.mqttDataFormat = config['mqtt_format']
self._mqttConn = mqtt.Client(client_id='RFLinkGateway')
--> self._mqttConn.username_pw_set(config['mqtt_username'], password=config['mqtt_password']) self._mqttConn.connect(config['mqtt_host'], port=config['mqtt_port'], keepalive=120)
added this line, so you can specify the username and password in the config file.