-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Labels
Description
Versions
- Python: 3.6
- OS: Ubuntu 18.04 LTS
- Pymodbus: 2.1.0
- Modbus Hardware (if used): N/A
Pymodbus Specific
- Client: TCP asyncio
Description
There is an issue where the async versions of the library dont respect the timeout.
I'm running the asyncio example here
and connecting to netcat running on the same machine.
However, the code always gets stuck like so:
DEBUG:root:Running Async client
DEBUG:root:------------------------------------------------------
DEBUG:asyncio:Using selector: EpollSelector
DEBUG:pymodbus.client.async.asyncio:Connecting to 10.10.10.14:23.
DEBUG:pymodbus.client.async.asyncio:Connecting.
DEBUG:pymodbus.client.async.asyncio:Client connected to modbus server
INFO:pymodbus.client.async.asyncio:Protocol made connection.
INFO:pymodbus.client.async.asyncio:Connected to 10.10.10.14:23.
DEBUG:root:Reading Coils
DEBUG:pymodbus.client.async.asyncio:send: 0x0 0x1 0x0 0x0 0x0 0x6 0x1 0x1 0x0 0x1 0x0 0x1
DEBUG:pymodbus.transaction:Adding transaction 1
What I expect to happen, is after 1s or so of no response, the query times out and the next one gets sent.
Hotfix
If anyone else has this issue before it is remedied, you can use the following code to add a timeout yourself:
rr = client.read_coils(1, 1, unit=0x01)
rr = await asyncio.wait_for(rr, timeout=3)