From 752a32e4893132eae916778e8bc1720b969e3786 Mon Sep 17 00:00:00 2001 From: "Brett T. Hannigan" Date: Sat, 22 Mar 2014 22:27:03 -0700 Subject: [PATCH] Changing code to try port 5672 first and then on exception try port 80. --- installer/install_suns.py | 16 ++++++++++------ src/__init__.py | 16 ++++++++++------ 2 files changed, 20 insertions(+), 12 deletions(-) diff --git a/installer/install_suns.py b/installer/install_suns.py index f9f5cbe..33653e8 100644 --- a/installer/install_suns.py +++ b/installer/install_suns.py @@ -134,12 +134,16 @@ def run(self): credentials = PlainCredentials('suns-client', 'suns-client') try: - # Connection initialization - connection = BlockingConnection( - ConnectionParameters( - host = self.suns_server_address, - credentials = credentials, - virtual_host = 'suns-vhost')) + def connect(port): + return BlockingConnection( + ConnectionParameters(host=self.suns_server_address, + port=port, + credentials=credentials, + virtual_host='suns-vhost')) + try: + connect(5672) + except: + connect(80) try: # Channel Initialization self.channel = connection.channel() diff --git a/src/__init__.py b/src/__init__.py index aea10ca..9e0e2bc 100644 --- a/src/__init__.py +++ b/src/__init__.py @@ -154,12 +154,16 @@ def run(self): credentials = PlainCredentials('suns-client', 'suns-client') try: - # Connection initialization - connection = BlockingConnection( - ConnectionParameters( - host = self.suns_server_address, - credentials = credentials, - virtual_host = 'suns-vhost')) + def connect(port): + return BlockingConnection( + ConnectionParameters(host=self.suns_server_address, + port=port, + credentials=credentials, + virtual_host='suns-vhost')) + try: + connect(5672) + except: + connect(80) try: # Channel Initialization self.channel = connection.channel()