Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/modbus-reconnect-10s.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"ftw": patch
---

A Modbus device that comes back after an outage is reached within 10 s. Core used to wait up to 60 s between reconnect attempts, so an inverter could hold its last forced battery mode for a minute after it returned.
5 changes: 4 additions & 1 deletion go/internal/modbus/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,10 @@ import (

const (
reconnectBackoffBase = 2 * time.Second
reconnectBackoffMax = 60 * time.Second
// A device that comes back must be reached within 10 s: until then it
// may hold the last forced battery mode. A dead endpoint costs one
// connect attempt per 10 s, well under the eviction threshold below.
reconnectBackoffMax = 10 * time.Second

// Many inverters accept exactly one Modbus TCP session and evict the
// previous one on every new connect. Redials above this rate almost
Expand Down
8 changes: 4 additions & 4 deletions go/internal/modbus/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -474,10 +474,10 @@ func TestReconnectBackoffSchedule(t *testing.T) {
2: 2 * time.Second,
3: 4 * time.Second,
4: 8 * time.Second,
5: 16 * time.Second,
6: 32 * time.Second,
7: 60 * time.Second,
8: 60 * time.Second,
5: 10 * time.Second,
6: 10 * time.Second,
7: 10 * time.Second,
8: 10 * time.Second,
}
for failures, delay := range want {
c.consecutiveTransportFailures = failures
Expand Down
Loading