From 1c36a208121ed4b86f6de51462621a876ce2acec Mon Sep 17 00:00:00 2001 From: Chris Burr Date: Mon, 24 Feb 2025 10:08:09 +0100 Subject: [PATCH] fix: Add wait timeout when connecting to stomp --- src/DIRAC/Resources/MessageQueue/StompMQConnector.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/DIRAC/Resources/MessageQueue/StompMQConnector.py b/src/DIRAC/Resources/MessageQueue/StompMQConnector.py index d8891152cd1..a9ea5266571 100644 --- a/src/DIRAC/Resources/MessageQueue/StompMQConnector.py +++ b/src/DIRAC/Resources/MessageQueue/StompMQConnector.py @@ -200,10 +200,14 @@ def connect(self, parameters=None): for _ in range(10): try: - # We need to explicitely call disconnect to avoid leaving - # threads behind + # We need to explicitly call disconnect to avoid leaving threads behind self.connection.disconnect() - self.connection.connect(username=user, passcode=password, wait=True) + + # Connect to the broker with a timeout of 30 seconds + self.connection.connect(username=user, passcode=password, wait=False) + self.transport.wait_for_connection(30) # pylint: disable=no-member + if self.transport.connection_error: # pylint: disable=no-member + raise stomp.exception.ConnectFailedException() if self.connection.is_connected(): # Go to the socket of the Stomp to find the remote host