Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 21 additions & 14 deletions nats/src/nats/aio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1458,22 +1458,29 @@ async def _check_connection_health(self) -> bool:
if not self.is_connected:
if self.options[
"allow_reconnect"
] and not self.is_reconnecting and not self.is_closed:
self._status = Client.RECONNECTING
self._ps.reset()

try:
if self._reconnection_task is not None and not self._reconnection_task.cancelled(
):
self._reconnection_task.cancel()

loop = asyncio.get_running_loop()
self._reconnection_task = loop.create_task(self._attempt_reconnect())

]:
if self.is_reconnecting:
await asyncio.sleep(self.options["reconnect_time_wait"])
return self.is_connected
except Exception:
return False

if not self.is_closed:
self._status = Client.RECONNECTING
self._ps.reset()

try:
if self._reconnection_task is not None and not self._reconnection_task.cancelled(
):
self._reconnection_task.cancel()

loop = asyncio.get_running_loop()
self._reconnection_task = loop.create_task(self._attempt_reconnect())

await asyncio.sleep(self.options["reconnect_time_wait"])
return self.is_connected
except Exception:
return False

return False
return False
return True

Expand Down