Comment 7 for bug 1073999

Revision history for this message
Gary Kotton (garyk) wrote :

Hi,
The problem is very easily reproducible. Please use the following script (if the eventlet.monkey_patch is commented then the open function will try and reconnect. If this is not commented then the function will hang).
Thanks
Gary

#!/usr/bin/env python

#import eventlet
#eventlet.monkey_patch()

import os
import time

from qpid.messaging import endpoints

print "QPID Test!"

session = None
consumers = {}
consumer_thread = None

default_params = dict(hostname='localhost',
                      port=5672,
                      username='',
                      password='')

params = {}
for key in default_params.keys():
    params.setdefault(key, default_params[key])

broker = params['hostname'] + ":" + str(params['port'])
# Create the connection - this does not open the connection
print "======> broker %s" % broker
connection = endpoints.Connection(broker)

# Check if flags are set and if so set them for the connection
# before we call open
connection.username = params['username']
connection.password = params['password']
connection.sasl_mechanisms = ''
connection.reconnect = True
connection.heartbeat = 60
connection.protocol = 'tcp'
connection.tcp_nodelay = True

while True:
    try:
        connection.open()
    except endpoints.exceptions.ConnectionError, e:
        print 'Unable to connect to AMQP server: %s' % e
        time.sleep(1)
    else:
        break

print 'Connected to AMQP server on %s' % broker