From 462cee04e5d952f544a8300dc5a0d1e297482e3f Mon Sep 17 00:00:00 2001 From: Vijay Venkatesh Kumar Date: Wed, 19 Oct 2022 15:25:42 +0000 Subject: Handle MR connection error Change-Id: I8defdd65093d19d4255427a8c7961cf5249007b8 Signed-off-by: Vijay Venkatesh Kumar Issue-ID: DCAEGEN2-2952 Signed-off-by: Vijay Venkatesh Kumar --- miss_htbt_service/htbtworker.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'miss_htbt_service') diff --git a/miss_htbt_service/htbtworker.py b/miss_htbt_service/htbtworker.py index ac7a0d9..0d43533 100644 --- a/miss_htbt_service/htbtworker.py +++ b/miss_htbt_service/htbtworker.py @@ -98,9 +98,14 @@ def process_msg(jsfile, user_name, password, ip_address, port_num, db_name): i = 0 break else: - res = requests.get(get_url) - msg = "HBT:", res.text - _logger.info(msg) + try: + res = requests.get(get_url) + except Exception as e: + # message-router may be down temporarily. continue polling loop to try again + _logger.error('HBT: Failed to fetch messages from DMaaP. get_url=%s', get_url, exc_info=e) + time.sleep(1) + continue + _logger.info("HBT: %s", res.text) input_string = res.text # If mrstatus in message body indicates some information, not json msg. if "mrstatus" in input_string: -- cgit 1.2.3-korg