stefanodimattia / nmodbus

Automatically exported from code.google.com/p/nmodbus
0 stars 0 forks source link

Timeout read operation closing TCPClient connection #69

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Connect to a tcp slave modbus device with a non infinite read timeout 
TCPClient (to test I connect to a tcp terminal, so that is no response to 
queries)
2. Send a readHoldingRegister message
3. Wait timeout

What is the expected output? What do you see instead?

Expected: Exception - read timeout. 

Received: Exception - Operation Invalid. Connection closed.

What version of the product are you using? On what operating system?

NModbus_net-3.5_1.11.0.0-source on Windows 7 Pro x64

Please provide any additional information below.

Looking at the code, I discovered that the retry mechanism catches the 
exception timeout and repeat the operation, but on the second attempt the TCP 
connection is closed for some reason and another exception is generated, 
masking the first one.

Original issue reported on code.google.com by alexrosa...@gmail.com on 5 Feb 2014 at 7:22

GoogleCodeExporter commented 8 years ago
I resolved closing Tcp connection and disposing the ModbusIpMaster object.
At next ping success, if you create new ModbusIpMaster object you will restore 
the connection to the device

Original comment by camnaghi...@gmail.com on 30 Apr 2014 at 8:26