I am trying to understand the link recovery mechanism. So for this, I am using a tcp modbus simulator. Sometimes I restart the server, or disconnect/ reconnect the simulator into the network.
So here's what I have observed. io.EOF is being propagated into the clients.
So, is connection recovery a built in feature of the library, or should be handle those from client side (by dropping the previous client).
Going deeper into the codebase, I see this:
|
} else if (err != io.EOF && err != io.ErrUnexpectedEOF) || |
|
mb.LinkRecoveryTimeout == 0 || time.Until(recoveryDeadline) < 0 { |
|
return |
|
} |
|
// any other error, but recovery deadline isn't reached yet - close and retry |
|
res = readResultCloseRetry |
|
return |
|
} |
The condition (err != io.EOF && err != io.ErrUnexpectedEOF) check feels convoluted. Also, readResultCloseRetry is not used anywhere else other than this assignment.
Feels like a logic bug, but I am not sure of the intention here too.
I am trying to understand the link recovery mechanism. So for this, I am using a tcp modbus simulator. Sometimes I restart the server, or disconnect/ reconnect the simulator into the network.
So here's what I have observed. io.EOF is being propagated into the clients.
So, is connection recovery a built in feature of the library, or should be handle those from client side (by dropping the previous client).
Going deeper into the codebase, I see this:
modbus/tcpclient.go
Lines 321 to 328 in 99e372e
The condition
(err != io.EOF && err != io.ErrUnexpectedEOF)check feels convoluted. Also,readResultCloseRetryis not used anywhere else other than this assignment.Feels like a logic bug, but I am not sure of the intention here too.