diff --git a/src/_ert/forward_model_runner/client.py b/src/_ert/forward_model_runner/client.py index 62fdd4056fb..a9390df9ccc 100644 --- a/src/_ert/forward_model_runner/client.py +++ b/src/_ert/forward_model_runner/client.py @@ -23,6 +23,7 @@ class ClientConnectionError(Exception): class Client: DEFAULT_MAX_RETRIES = 10 DEFAULT_ACK_TIMEOUT = 5 + DEFAULT_CONNECT_RETRIES = 1 def __init__( self, @@ -83,7 +84,7 @@ async def connect(self) -> None: await self._term_receiver_task() self._receiver_task = asyncio.create_task(self._receiver()) try: - await self.send(CONNECT_MSG, retries=1) + await self.send(CONNECT_MSG, retries=self.DEFAULT_CONNECT_RETRIES) except ClientConnectionError: await self._term_receiver_task() self.term() @@ -136,13 +137,14 @@ async def send(self, message: str | bytes, retries: int | None = None) -> None: self.term() raise - retries -= 1 if retries > 0: logger.info(f"Retrying... ({retries} attempts left)") await asyncio.sleep(backoff) # this call is idempotent + self.socket.disconnect(self.url) self.socket.connect(self.url) backoff = min(backoff * 2, 10) # Exponential backoff + retries -= 1 raise ClientConnectionError( f"{self.dealer_id} Failed to send {message!r} after retries!" )