Skip to content

serial async client 3.0.2 timeout always takes 3,0s no matter the value set to timeout #1230

@bsense-rius

Description

@bsense-rius

Versions

  • Python: 3,8
  • OS: 22.04, 20.04
  • Pymodbus: 3.0,2
  • Modbus Hardware (if used): Different sensors: Temperature, GPIO

Pymodbus Specific

  • Server: NA
  • Client: rtu - async

Description

Whenever there is an issue with the sensor (power loss, wiring problem) the AsyncModbusSerialClient always times out after 3.0s, despite that during the client instantiation we set a timeout with a different value.

What were you trying, what has happened, what went wrong, and what did you expect?
It can be easily repeated: just disconnect the 485 (modbus) connection cables from the peripheral and timeout raises after 3.0s

I had already reported this issue 6 weeks ago: timeout issue

GraciousGpal pointed out that this issue was also present in AsyncModbusTCPClient(). He worked out a solution that when I apply to AsyncModbusSerialClient() works too,

It seemed, though, that his comment lead to fix the same issue for AyncModbusTCPClient(), but it was not applied to AsyncSerialModbusClient)()

Code and Logs

# code and logs here.

# please use the following to format logs when posting them here
import pymodbus
pymodbus.pymodbus_apply_logging_config()

...
                        client =  AsyncModbusSerialClient(port=self.commPort, baudrate=self.commSpeed, timeout=self.commTimeout)
                        await client.connect()
                        self.client = client

                        # Fix timeout issue. Otherwise it takes default 3.0s
                        self.client.protocol.params.timeout = self.commTimeout
                        self.client.protocol.transaction.client.params.timeout = self.commTimeout

...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions