@@ -399,6 +399,7 @@ def connect(
399
399
host : Optional [str ] = None ,
400
400
port : Optional [int ] = None ,
401
401
keep_alive : Optional [int ] = None ,
402
+ session_id : Optional [str ] = None ,
402
403
) -> int :
403
404
"""Initiates connection with the MQTT Broker. Will perform exponential back-off
404
405
on connect failures.
@@ -408,7 +409,8 @@ def connect(
408
409
:param int port: Network port of the remote broker.
409
410
:param int keep_alive: Maximum period allowed for communication
410
411
within single connection attempt, in seconds.
411
-
412
+ :param str session_id: unique session ID,
413
+ used for multiple simultaneous connections to the same host
412
414
"""
413
415
414
416
last_exception = None
@@ -430,6 +432,7 @@ def connect(
430
432
host = host ,
431
433
port = port ,
432
434
keep_alive = keep_alive ,
435
+ session_id = session_id
433
436
)
434
437
self ._reset_reconnect_backoff ()
435
438
return ret
@@ -467,13 +470,16 @@ def _connect( # noqa: PLR0912, PLR0915, Too many branches, Too many statements
467
470
host : Optional [str ] = None ,
468
471
port : Optional [int ] = None ,
469
472
keep_alive : Optional [int ] = None ,
473
+ session_id : Optional [str ] = None ,
470
474
) -> int :
471
475
"""Initiates connection with the MQTT Broker.
472
476
473
477
:param bool clean_session: Establishes a persistent session.
474
478
:param str host: Hostname or IP address of the remote broker.
475
479
:param int port: Network port of the remote broker.
476
480
:param int keep_alive: Maximum period allowed for communication, in seconds.
481
+ :param str session_id: unique session ID,
482
+ used for multiple simultaneous connections to the same host
477
483
478
484
"""
479
485
if host :
@@ -496,6 +502,7 @@ def _connect( # noqa: PLR0912, PLR0915, Too many branches, Too many statements
496
502
self .broker ,
497
503
self .port ,
498
504
proto = "mqtt:" ,
505
+ session_id = session_id ,
499
506
timeout = self ._socket_timeout ,
500
507
is_ssl = self ._is_ssl ,
501
508
ssl_context = self ._ssl_context ,
0 commit comments