@@ -222,25 +222,9 @@ def connect(self, clean_session=True):
222222 :param bool clean_session: Establishes a persistent session.
223223
224224 """
225- try :
226- proto , dummy , broker , path = self .broker .split ("/" , 3 )
227- # replace spaces in path
228- path = path .replace (" " , "%20" )
229- except ValueError :
230- proto , dummy , broker = self .broker .split ("/" , 2 )
231- path = ""
232- if proto == "http:" :
233- self .port = MQTT_TCP_PORT
234- elif proto == "https:" :
235- self .port = MQTT_TLS_PORT
236- else :
237- raise ValueError ("Unsupported protocol: " + proto )
238-
239- if ":" in broker :
240- broker , port = broker .split (":" , 1 )
241- port = int (port )
242-
243- addr = _the_sock .getaddrinfo (broker , self .port , 0 , _the_sock .SOCK_STREAM )[0 ]
225+ addr = _the_sock .getaddrinfo (self .broker , self .port , 0 , _the_sock .SOCK_STREAM )[
226+ 0
227+ ]
244228 self ._sock = _the_sock .socket (addr [0 ], addr [1 ], addr [2 ])
245229 self ._sock .settimeout (15 )
246230 if self .port == 8883 :
@@ -249,7 +233,7 @@ def connect(self, clean_session=True):
249233 self .logger .debug (
250234 "Attempting to establish secure MQTT connection..."
251235 )
252- self ._sock .connect ((broker , self .port ), _the_interface .TLS_MODE )
236+ self ._sock .connect ((self . broker , self .port ), _the_interface .TLS_MODE )
253237 except RuntimeError as e :
254238 raise MMQTTException ("Invalid broker address defined." , e )
255239 else :
0 commit comments