Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question: how to specify username and password for MQTT broker? #13

Open
draakje111 opened this issue Dec 2, 2018 · 1 comment
Open

Comments

@draakje111
Copy link

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.

@draakje111
Copy link
Author

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant