mirror of
https://github.com/henrygd/beszel.git
synced 2026-09-21 17:07:47 +02:00
fix(agent): extend WebSocket deadline for slow collections (#2297)
The agent resets its WebSocket deadline to 70s, but the hub's default collection interval is 60s, so a single slow collection cycle is enough to trip the deadline and start a reconnect loop even though the hub is still serving the agent. Raise the deadline to 120s and add a regression test that keeps the slow-collection window from being lowered below two minutes. Verified with go test -tags=testing ./agent (focused tests and the full agent suite minus the container-only TestDirectoryIsWritable case), go vet, the agent build and gofmt. Closes #2294
This commit is contained in:
@@ -25,7 +25,9 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
wsDeadline = 70 * time.Second
|
// Keep the connection alive long enough for a slow collection cycle to
|
||||||
|
// finish before the hub considers the agent disconnected.
|
||||||
|
wsDeadline = 120 * time.Second
|
||||||
)
|
)
|
||||||
|
|
||||||
type caCertFileError struct {
|
type caCertFileError struct {
|
||||||
|
|||||||
@@ -700,3 +700,11 @@ func TestGetToken(t *testing.T) {
|
|||||||
assert.Equal(t, expectedToken, token, "Whitespace should be stripped from token file content")
|
assert.Equal(t, expectedToken, token, "Whitespace should be stripped from token file content")
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestWebSocketDeadlineCoversSlowCollection(t *testing.T) {
|
||||||
|
const minimumDeadline = 120 * time.Second
|
||||||
|
|
||||||
|
if wsDeadline < minimumDeadline {
|
||||||
|
t.Fatalf("WebSocket deadline %s is shorter than the slow-collection window of %s", wsDeadline, minimumDeadline)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user