@@ -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
@@ -482,13 +485,16 @@ def _connect( # noqa: PLR0912, PLR0915, Too many branches, Too many statements
482
485
host : Optional [str ] = None ,
483
486
port : Optional [int ] = None ,
484
487
keep_alive : Optional [int ] = None ,
488
+ session_id : Optional [str ] = None ,
485
489
) -> int :
486
490
"""Initiates connection with the MQTT Broker.
487
491
488
492
:param bool clean_session: Establishes a persistent session.
489
493
:param str host: Hostname or IP address of the remote broker.
490
494
:param int port: Network port of the remote broker.
491
495
:param int keep_alive: Maximum period allowed for communication, in seconds.
496
+ :param str session_id: unique session ID,
497
+ used for multiple simultaneous connections to the same host
492
498
493
499
"""
494
500
if host :
@@ -511,6 +517,7 @@ def _connect( # noqa: PLR0912, PLR0915, Too many branches, Too many statements
511
517
self .broker ,
512
518
self .port ,
513
519
proto = "mqtt:" ,
520
+ session_id = session_id ,
514
521
timeout = self ._socket_timeout ,
515
522
is_ssl = self ._is_ssl ,
516
523
ssl_context = self ._ssl_context ,
0 commit comments