Can use the following code to recreate the issue. Attempts to reconnect to RabbitMQ server 2 seconds after connection timeout if server is down. If you start the server while this test-code is running, Rabbitpy will hang.
import rabbitpy
import time
import logging
logging.basicConfig(level=logging.DEBUG)
AMQP_RECONNECT_TIMEOUT_s = 2
conn_string="amqp://guest:guest@localhost:5672/%2f"
while True:
try:
with rabbitpy.Connection() as conn:
with conn.channel() as chan:
logging.info("Connected to: ")
time.sleep(5)
except RuntimeError:
logging.error("Failed to connect to AMQP: " + conn_string)
finally:
time.sleep(AMQP_RECONNECT_TIMEOUT_s)
The debug printout stops after "Writing frame: ProtocolHeader"
2021-07-12 07:43:53,032 DEBUG Connection setting state to 'Opening' | base.py:99
2021-07-12 07:43:53,032 DEBUG IO setting state to 'Opening' | base.py:99
2021-07-12 07:43:53,033 DEBUG Waiting for 3 seconds on event: Socket Connected | events.py:131
2021-07-12 07:43:53,033 DEBUG Connecting to ('127.0.0.1', 5672) | io.py:532
2021-07-12 07:43:53,033 DEBUG Error connecting to ('127.0.0.1', 5672): [Errno 111] Connection refused | io.py:552
2021-07-12 07:43:53,034 WARNING Could not connect to localhost:5672 | io.py:396
2021-07-12 07:44:01,035 DEBUG Connection setting state to 'Opening' | base.py:99
2021-07-12 07:44:01,035 DEBUG IO setting state to 'Opening' | base.py:99
2021-07-12 07:44:01,036 DEBUG Waiting for 3 seconds on event: Socket Connected | events.py:131
2021-07-12 07:44:01,036 DEBUG Connecting to ('127.0.0.1', 5672) | io.py:532
2021-07-12 07:44:01,036 DEBUG IO setting state to 'Open' | base.py:99
2021-07-12 07:44:01,036 DEBUG Socket connected | io.py:400
2021-07-12 07:44:01,036 DEBUG Returning PollPoller | io.py:238
2021-07-12 07:44:01,037 DEBUG Adding channel 0 to io | connection.py:246
2021-07-12 07:44:01,037 DEBUG Channel0 setting state to 'Opening' | base.py:99
2021-07-12 07:44:01,037 DEBUG Writing frame: ProtocolHeader | base.py:253
Can use the following code to recreate the issue. Attempts to reconnect to RabbitMQ server 2 seconds after connection timeout if server is down. If you start the server while this test-code is running, Rabbitpy will hang.
The debug printout stops after "Writing frame: ProtocolHeader"