pymodbus
pymodbus copied to clipboard
ReconnectingAsyncioModbusTcpClient.start yields an invalid client when the first connection does not succeed
Description
ReconnectingAsyncioModbusTcpClient.start does start a client that tries to reconnect, but when the first connection attempt fails, the client is returned immediately instead of waiting for the next attempt.
Code and Logs
from pymodbus.client.asynchronous.asyncio import ReconnectingAsyncioModbusTcpClient
client = ReconnectingAsyncioModbusTcpClient()
await client.start(host=host, port=port)
print(client.protocol)
When the connection fails in client.start, one could expect that the client will retry the connection and yield a value only when the connection is established, or at least that it will raise an error. Instead, the connection silently fails, and the client is left in a state where client.protocol is None.