It looks like the retries do not work when using an UdpClient.
UdpClient throws an SocketError since it throws a SocketException when there is a read timeout of the acknowledge due to packet loss.
at System.Net.Sockets.Socket.Receive(Byte[] buffer)
at NModbus.IO.UdpClientAdapter.Read(Byte[] buffer, Int32 offset, Int32 count) in ...NModbus-3.0.80\NModbus\IO\UdpClientAdapter.cs:line 87
at NModbus.IO.ModbusIpTransport.ReadRequestResponse(IStreamResource streamResource, IModbusLogger logger) in ...NModbus-3.0.80\NModbus\IO\ModbusIpTransport.cs:line 36
at NModbus.IO.ModbusIpTransport.ReadResponse[T]() in ...NModbus-3.0.80\NModbus\IO\ModbusIpTransport.cs:line 142
at NModbus.IO.ModbusTransport.UnicastMessage[T](IModbusMessage message) in ...NModbus-3.0.80\NModbus\IO\ModbusTransport.cs:line 137
A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond.
Right now this walks falls through the retries to the throw at line 198.
I can make it work with an additional e is SocketException in the if() at L189
|
if (e is FormatException || |
Is this a viable fix?
It looks like the retries do not work when using an UdpClient.
UdpClient throws an SocketError since it throws a SocketException when there is a read timeout of the acknowledge due to packet loss.
Right now this walks falls through the retries to the
throwat line 198.NModbus/NModbus/IO/ModbusTransport.cs
Line 205 in a1d9b8c
I can make it work with an additional
e is SocketExceptionin the if() at L189NModbus/NModbus/IO/ModbusTransport.cs
Line 189 in a1d9b8c
Is this a viable fix?