@@ -203,8 +203,8 @@ def __init__(
203
203
self .on_subscribe = None
204
204
self .on_unsubscribe = None
205
205
206
- def _get_socket (self , host , port , * , timeout = 1 ):
207
- """Obtains and connects a new socket to a host .
206
+ def _get_connect_socket (self , host , port , * , timeout = 1 ):
207
+ """Obtains a new socket and connects to a broker .
208
208
:param str host: Desired broker hostname
209
209
:param int port: Desired broker port
210
210
:param int timeout: Desired socket timeout
@@ -214,15 +214,15 @@ def _get_socket(self, host, port, *, timeout=1):
214
214
self ._sock .close ()
215
215
self ._sock = None
216
216
217
- # Legacy API - use a default socket instead of socket pool
217
+ # Legacy API - use the interface's socket instead of a passed socket pool
218
218
if self ._socket_pool is None :
219
219
self ._socket_pool = _default_sock
220
220
221
221
# Legacy API - fake the ssl context
222
222
if self ._ssl_context is None :
223
223
self ._ssl_context = _fake_context
224
224
225
- if port == 8883 and self ._ssl_context is None :
225
+ if port == 8883 and not self ._ssl_context :
226
226
raise RuntimeError (
227
227
"ssl_context must be set before using adafruit_mqtt for secure MQTT."
228
228
)
@@ -425,7 +425,7 @@ def connect(self, clean_session=True, host=None, port=None, keep_alive=None):
425
425
self .logger .debug ("Attempting to establish MQTT connection..." )
426
426
427
427
# Get a new socket
428
- self ._sock = self ._get_socket (self .broker , self .port )
428
+ self ._sock = self ._get_connect_socket (self .broker , self .port )
429
429
430
430
# Fixed Header
431
431
fixed_header = bytearray ([0x10 ])
0 commit comments