Skip to content

Commit

Permalink
Moved CLIENT_ID check in init_app
Browse files Browse the repository at this point in the history
To prevent the client id from being ignored I moved the check for it to before the check if it is unicode.
  • Loading branch information
skrapi committed Sep 17, 2020
1 parent 2b036fb commit 178c645
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions flask_mqtt/__init__.py
Expand Up @@ -105,6 +105,10 @@ def __init__(

def init_app(self, app: Flask) -> None:
"""Init the Flask-MQTT addon."""

if "MQTT_CLIENT_ID" in app.config:
self.client_id = app.config["MQTT_CLIENT_ID"]

if isinstance(self.client_id, unicode):
self.client._client_id = self.client_id.encode("utf-8")
else:
Expand All @@ -116,9 +120,6 @@ def init_app(self, app: Flask) -> None:
self.client.on_connect = self._handle_connect
self.client.on_disconnect = self._handle_disconnect

if "MQTT_CLIENT_ID" in app.config:
self.client_id = app.config["MQTT_CLIENT_ID"]

if "MQTT_CLEAN_SESSION" in app.config:
self.clean_session = app.config["MQTT_CLEAN_SESSION"]

Expand Down

0 comments on commit 178c645

Please sign in to comment.