Skip to content

Commit 1c36a20

Browse files
committed
fix: Add wait timeout when connecting to stomp
1 parent 83762a6 commit 1c36a20

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/DIRAC/Resources/MessageQueue/StompMQConnector.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -200,10 +200,14 @@ def connect(self, parameters=None):
200200

201201
for _ in range(10):
202202
try:
203-
# We need to explicitely call disconnect to avoid leaving
204-
# threads behind
203+
# We need to explicitly call disconnect to avoid leaving threads behind
205204
self.connection.disconnect()
206-
self.connection.connect(username=user, passcode=password, wait=True)
205+
206+
# Connect to the broker with a timeout of 30 seconds
207+
self.connection.connect(username=user, passcode=password, wait=False)
208+
self.transport.wait_for_connection(30) # pylint: disable=no-member
209+
if self.transport.connection_error: # pylint: disable=no-member
210+
raise stomp.exception.ConnectFailedException()
207211

208212
if self.connection.is_connected():
209213
# Go to the socket of the Stomp to find the remote host

0 commit comments

Comments
 (0)