Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Connection hangs when attempting to connect to a booting server #133

Open
AndTornes opened this issue Jul 12, 2021 · 0 comments
Open

Connection hangs when attempting to connect to a booting server #133

AndTornes opened this issue Jul 12, 2021 · 0 comments

Comments

@AndTornes
Copy link
Contributor

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
AndTornes added a commit to AndTornes/rabbitpy that referenced this issue Jul 12, 2021
gmr added a commit that referenced this issue Jul 30, 2024
Prevent lock-up when connecting to a booting server (#133)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant