Update dependencies and remove old matterclient lib (#2067)

This commit is contained in:
Wim
2023-08-05 20:43:19 +02:00
committed by GitHub
parent 9459495484
commit 56e7bd01ca
772 changed files with 139315 additions and 121315 deletions

View File

@@ -23,10 +23,13 @@ var (
KeepAliveIntervalMin = 20 * time.Second
// KeepAliveIntervalMax specifies the maximum interval for websocket keepalive pings.
KeepAliveIntervalMax = 30 * time.Second
// KeepAliveMaxFailTime specifies the maximum time to wait before forcing a reconnect if keepalives fail repeatedly.
KeepAliveMaxFailTime = 3 * time.Minute
)
func (cli *Client) keepAliveLoop(ctx context.Context) {
var lastSuccess time.Time
lastSuccess := time.Now()
var errorCount int
for {
interval := rand.Int63n(KeepAliveIntervalMax.Milliseconds()-KeepAliveIntervalMin.Milliseconds()) + KeepAliveIntervalMin.Milliseconds()
@@ -41,6 +44,11 @@ func (cli *Client) keepAliveLoop(ctx context.Context) {
ErrorCount: errorCount,
LastSuccess: lastSuccess,
})
if cli.EnableAutoReconnect && time.Since(lastSuccess) > KeepAliveMaxFailTime {
cli.Log.Debugf("Forcing reconnect due to keepalive failure")
cli.Disconnect()
go cli.autoReconnect()
}
} else {
if errorCount > 0 {
errorCount = 0