From 2994873956d7ded2274007472c6327c55286a232 Mon Sep 17 00:00:00 2001 From: jan iversen Date: Sun, 13 Aug 2023 08:56:46 +0200 Subject: [PATCH] Correct retry loop. --- pymodbus/client/base.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pymodbus/client/base.py b/pymodbus/client/base.py index 42c07d1b9..5c23acfe2 100644 --- a/pymodbus/client/base.py +++ b/pymodbus/client/base.py @@ -198,13 +198,14 @@ async def async_execute(self, request=None): while count < self.params.retries: count += 1 try: + req = self._build_response(request.transaction_id) resp = await asyncio.wait_for( req, timeout=self.comm_params.timeout_connect ) break except asyncio.exceptions.TimeoutError: pass - if count == self.params.retries: + if count > self.params.retries: self.close(reconnect=True) raise ModbusIOException( f"ERROR: No response received after {self.params.retries} retries"