Update dependencies and remove old matterclient lib (#2067)
This commit is contained in:
10
vendor/go.mau.fi/whatsmeow/keepalive.go
vendored
10
vendor/go.mau.fi/whatsmeow/keepalive.go
vendored
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user