Skip to content

Commit

Permalink
retry on ConnectionException
Browse files Browse the repository at this point in the history
  • Loading branch information
jesseklm committed Jul 9, 2024
1 parent e4724fe commit 498f2a3
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions modbus4mqtt/modbus_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import logging
from queue import Queue
from pymodbus.client.sync import ModbusTcpClient, ModbusSocketFramer
from pymodbus import exceptions
from pymodbus.exceptions import ConnectionException
from SungrowModbusTcpClient import SungrowModbusTcpClient

DEFAULT_SCAN_RATE_S = 5
Expand Down Expand Up @@ -57,7 +57,7 @@ def __init__(self, ip: str, port: int = 502, update_rate_s: int = DEFAULT_SCAN_R
def connect(self) -> bool:
try:
return self._mb.connect()
except ConnectionResetError as e:
except (ConnectionResetError, ConnectionException) as e:
logging.exception(f"{e}")
return False

Expand Down

0 comments on commit 498f2a3

Please sign in to comment.