Skip to content

Commit

Permalink
better mqtt reconnections
Browse files Browse the repository at this point in the history
  • Loading branch information
CamDavidsonPilon committed Sep 19, 2024
1 parent 14c97e6 commit 5b39be6
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions pioreactor/background_jobs/monitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,7 @@ def check_for_mqtt_connection_to_leader(self) -> None:
while (not self.pub_client.is_connected()) or (not self.sub_client.is_connected()):
self.logger.warning(
f"""Not able to connect MQTT clients to leader.
1. Is the mqtt_adress={get_mqtt_address()}, in config.ini correct?
1. Is the mqtt_adress={get_mqtt_address()} in configuration correct?
2. Is the Pioreactor leader online and responsive?
"""
) # remember, this doesn't get published to leader...
Expand All @@ -452,18 +452,20 @@ def check_for_mqtt_connection_to_leader(self) -> None:
error_code_pc = (
self.pub_client.reconnect()
) # this may return a MQTT_ERR_SUCCESS, but that only means the CONNECT message is sent, still waiting for a CONNACK.
self.pub_client.loop_start()
self.logger.debug(f"{error_code_pc=}")
except Exception as e:
self.logger.debug(f"{e=}")

try:
self.sub_client.disconnect()
error_code_sc = self.sub_client.reconnect()
self.sub_client.loop_start()
self.logger.debug(f"{error_code_sc=}")
except Exception as e:
self.logger.debug(f"{e=}")

sleep(1)
sleep(2)

# self.set_state(self.LOST)

Expand Down

0 comments on commit 5b39be6

Please sign in to comment.