1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-27 09:25:10 +03:00

Merge pull request #6724 from chrismeyersfsu/fix-redis_not_registering_disconnect

reconnect when a vanilla server disconnect happens

Reviewed-by: https://github.com/apps/softwarefactory-project-zuul
This commit is contained in:
softwarefactory-project-zuul[bot] 2020-04-15 23:38:47 +00:00 committed by GitHub
commit a989c624c7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -93,7 +93,7 @@ class WebsocketTask():
try: try:
async with aiohttp.ClientSession(headers={'secret': secret_val}, async with aiohttp.ClientSession(headers={'secret': secret_val},
timeout=timeout) as session: timeout=timeout) as session:
async with session.ws_connect(uri, ssl=self.verify_ssl) as websocket: async with session.ws_connect(uri, ssl=self.verify_ssl, heartbeat=20) as websocket:
self.stats.record_connection_established() self.stats.record_connection_established()
attempt = 0 attempt = 0
await self.run_loop(websocket) await self.run_loop(websocket)
@ -105,15 +105,12 @@ class WebsocketTask():
raise raise
except client_exceptions.ClientConnectorError as e: except client_exceptions.ClientConnectorError as e:
logger.warn(f"Failed to connect to {self.remote_host}: '{e}'. Reconnecting ...") logger.warn(f"Failed to connect to {self.remote_host}: '{e}'. Reconnecting ...")
self.stats.record_connection_lost()
self.start(attempt=attempt + 1)
except asyncio.TimeoutError: except asyncio.TimeoutError:
logger.warn(f"Timeout while trying to connect to {self.remote_host}. Reconnecting ...") logger.warn(f"Timeout while trying to connect to {self.remote_host}. Reconnecting ...")
self.stats.record_connection_lost()
self.start(attempt=attempt + 1)
except Exception as e: except Exception as e:
# Early on, this is our canary. I'm not sure what exceptions we can really encounter. # Early on, this is our canary. I'm not sure what exceptions we can really encounter.
logger.warn(f"Websocket broadcast client exception {type(e)} {e}") logger.warn(f"Websocket broadcast client exception {type(e)} {e}")
self.stats.record_connection_lost() self.stats.record_connection_lost()
self.start(attempt=attempt + 1) self.start(attempt=attempt + 1)