-
Notifications
You must be signed in to change notification settings - Fork 1k
Closed
Description
Versions
- Python: 3.10.5
- OS: Windows 11 x64
- Pymodbus: 1.5.2, 2.5.3, 3.0.0.dev4
- Modbus Hardware (if used):
Pymodbus Specific
- Server: tcp/rtu/ascii - sync/async
- Client: tcp/rtu/ascii - sync/async
Description
Running the forwarder example with tcp slave and tcp server each request to the server is sent twice to the slave when it should be sent once.
Code and Logs
For testing purposed I created the forwarder like this (unit 248 --> 247):
context = ModbusServerContext(slaves={248: RemoteSlaveContext(client, unit=247)}, single=False)Now when a client asks the forwarder to read first holding register, this is what happens at the forwarder:
# code and logs here.
03:59:19,280 MainThread DEBUG sync :215 Connection to Modbus server established. Socket ('192.168.178.53', 52413)
04:05:06,214 MainThread DEBUG sync :348 Started thread to serve client at ('127.0.0.1', 52754)
04:05:06,214 Thread-1 ( DEBUG sync :46 Client Connected [127.0.0.1:52754]
04:05:06,214 Thread-1 ( DEBUG sync :199 Handling data: 0x0 0x1 0x0 0x0 0x0 0x6 0xf8 0x3 0x0 0x0 0x0 0x1
04:05:06,214 Thread-1 ( DEBUG socket_framer :147 Processing: 0x0 0x1 0x0 0x0 0x0 0x6 0xf8 0x3 0x0 0x0 0x0 0x1
04:05:06,214 Thread-1 ( DEBUG factory :137 Factory Request[ReadHoldingRegistersRequest: 3]
04:05:06,214 Thread-1 ( DEBUG remote :42 validate[3] 0:1
04:05:06,214 Thread-1 ( DEBUG transaction :139 Current transaction state - IDLE
04:05:06,214 Thread-1 ( DEBUG transaction :144 Running transaction 1
04:05:06,214 Thread-1 ( DEBUG transaction :273 SEND: 0x0 0x1 0x0 0x0 0x0 0x6 0xf7 0x3 0x0 0x0 0x0 0x1
04:05:06,214 Thread-1 ( DEBUG sync :76 New Transaction state 'SENDING'
04:05:06,214 Thread-1 ( DEBUG transaction :287 Changing transaction state from 'SENDING' to 'WAITING FOR REPLY'
04:05:06,399 Thread-1 ( DEBUG transaction :375 Changing transaction state from 'WAITING FOR REPLY' to 'PROCESSING REPLY'
04:05:06,399 Thread-1 ( DEBUG transaction :297 RECV: 0x0 0x1 0x0 0x0 0x0 0x5 0xf7 0x3 0x2 0x15 0xc5
04:05:06,399 Thread-1 ( DEBUG socket_framer :147 Processing: 0x0 0x1 0x0 0x0 0x0 0x5 0xf7 0x3 0x2 0x15 0xc5
04:05:06,399 Thread-1 ( DEBUG factory :266 Factory Response[ReadHoldingRegistersResponse: 3]
04:05:06,399 Thread-1 ( DEBUG transaction :454 Adding transaction 1
04:05:06,399 Thread-1 ( DEBUG transaction :465 Getting transaction 1
04:05:06,399 Thread-1 ( DEBUG transaction :224 Changing transaction state from 'PROCESSING REPLY' to 'TRANSACTION_COMPLETE'
04:05:06,399 Thread-1 ( DEBUG remote :55 get values[3] 0:1
04:05:06,399 Thread-1 ( DEBUG transaction :139 Current transaction state - TRANSACTION_COMPLETE
04:05:06,399 Thread-1 ( DEBUG transaction :144 Running transaction 2
04:05:06,399 Thread-1 ( DEBUG transaction :273 SEND: 0x0 0x2 0x0 0x0 0x0 0x6 0xf7 0x3 0x0 0x0 0x0 0x1
04:05:06,399 Thread-1 ( DEBUG sync :76 New Transaction state 'SENDING'
04:05:06,399 Thread-1 ( DEBUG transaction :287 Changing transaction state from 'SENDING' to 'WAITING FOR REPLY'
04:05:06,524 Thread-1 ( DEBUG transaction :375 Changing transaction state from 'WAITING FOR REPLY' to 'PROCESSING REPLY'
04:05:06,524 Thread-1 ( DEBUG transaction :297 RECV: 0x0 0x2 0x0 0x0 0x0 0x5 0xf7 0x3 0x2 0x15 0xc5
04:05:06,524 Thread-1 ( DEBUG socket_framer :147 Processing: 0x0 0x2 0x0 0x0 0x0 0x5 0xf7 0x3 0x2 0x15 0xc5
04:05:06,524 Thread-1 ( DEBUG factory :266 Factory Response[ReadHoldingRegistersResponse: 3]
04:05:06,524 Thread-1 ( DEBUG transaction :454 Adding transaction 2
04:05:06,524 Thread-1 ( DEBUG transaction :465 Getting transaction 2
04:05:06,524 Thread-1 ( DEBUG transaction :224 Changing transaction state from 'PROCESSING REPLY' to 'TRANSACTION_COMPLETE'
04:05:06,524 Thread-1 ( DEBUG sync :229 send: [ReadHoldingRegistersResponse (1)]- b'000100000005f8030215c5'
04:05:06,540 Thread-1 ( DEBUG sync :199 Handling data:
04:05:06,540 Thread-1 ( DEBUG socket_framer :147 Processing:
04:05:06,540 Thread-1 ( DEBUG sync :54 Client Disconnected [127.0.0.1:52754]I can confirm the actual slave receives the request twice as well. This is true for pymodbus 1.5.2, 2.5.3 as well as 3.0.0.dev4.