Skip to content

Commit b7cbb44

Browse files
author
Jim Bennett
committed
Using a copy of the borker name when splitting
Fix for adafruit#26
1 parent bd24155 commit b7cbb44

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

adafruit_minimqtt.py

+6-6
Original file line numberDiff line numberDiff line change
@@ -223,11 +223,11 @@ def connect(self, clean_session=True):
223223
224224
"""
225225
try:
226-
proto, dummy, self.broker, path = self.broker.split("/", 3)
226+
proto, dummy, broker, path = self.broker.split("/", 3)
227227
# replace spaces in path
228228
path = path.replace(" ", "%20")
229229
except ValueError:
230-
proto, dummy, self.broker = self.broker.split("/", 2)
230+
proto, dummy, broker = self.broker.split("/", 2)
231231
path = ""
232232
if proto == "http:":
233233
self.port = MQTT_TCP_PORT
@@ -236,11 +236,11 @@ def connect(self, clean_session=True):
236236
else:
237237
raise ValueError("Unsupported protocol: " + proto)
238238

239-
if ":" in self.broker:
240-
self.broker, port = self.broker.split(":", 1)
239+
if ":" in broker:
240+
broker, port = broker.split(":", 1)
241241
port = int(port)
242242

243-
addr = _the_sock.getaddrinfo(self.broker, self.port, 0, _the_sock.SOCK_STREAM)[
243+
addr = _the_sock.getaddrinfo(broker, self.port, 0, _the_sock.SOCK_STREAM)[
244244
0
245245
]
246246
self._sock = _the_sock.socket(addr[0], addr[1], addr[2])
@@ -251,7 +251,7 @@ def connect(self, clean_session=True):
251251
self.logger.debug(
252252
"Attempting to establish secure MQTT connection..."
253253
)
254-
self._sock.connect((self.broker, self.port), _the_interface.TLS_MODE)
254+
self._sock.connect((broker, self.port), _the_interface.TLS_MODE)
255255
except RuntimeError as e:
256256
raise MMQTTException("Invalid broker address defined.", e)
257257
else:

0 commit comments

Comments
 (0)